@devries-cameron20 / t3code Mirror · read-only / commits / 4bf5d53d93
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 21:00 UTC

fix(forgejo): HTTP-only fj logins are no longer reported unauthenticated (#34777)

Julius Marminge committed Nov 11, 2026 at 22:35 UTC 4bf5d53d93eedc45ca67d4042a33ca974a8ef567
2 files changed +85 -5
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
+73
@@ -2036,3 +2036,76 @@ it.effect("explains a slow fj instead of advising an install when tea is absent"
2036 ),
2037 ),
2038 );
2039 +
2040 +it.effect("does not call a valid fj login on an HTTP-only server unauthenticated", () =>
2041 + Effect.gen(function* () {
2042 + const spec = yield* ForgejoSourceControlProvider.makeDiscovery.pipe(
2043 + Effect.provide(ForgejoCli.layer),
2044 + );
2045 + assert.strictEqual(spec.type, "managed-cli");
2046 + if (spec.type !== "managed-cli") return;
2047 + const result = yield* spec.probe("/repo");
2048 + assert.strictEqual(result.executable, "fj");
2049 + assert.notStrictEqual(result.auth.status, "unauthenticated");
2050 + }).pipe(
2051 + Effect.provideService(
2052 + FileSystem.FileSystem,
2053 + FileSystem.makeNoop({
2054 + exists: () => Effect.succeed(true),
2055 + // fj stores the host without the scheme the login used.
2056 + readFileString: () =>
2057 + Effect.succeed(
2058 + encodeJson({
2059 + hosts: { "forgejo.local:3000": { type: "Application", token: "test-token" } },
2060 + }),
2061 + ),
2062 + }),
2063 + ),
2064 + Effect.provideService(
2065 + HttpClient.HttpClient,
2066 + HttpClient.make((request) =>
2067 + request.url.startsWith("http://")
2068 + ? Effect.succeed(
2069 + HttpClientResponse.fromWeb(
2070 + request,
2071 + new Response(encodeJson({ login: "maria" }), { status: 200 }),
2072 + ),
2073 + )
2074 + : Effect.die(new Error("received corrupt message of type InvalidContentType")),
2075 + ),
2076 + ),
2077 + Effect.provide(
2078 + TestSourceControlHost.layer({
2079 + process: {
2080 + run: (input) => {
2081 + // Settings has no project in scope, so there is no origin remote.
2082 + if (input.command === "git")
2083 + return Effect.succeed(
2084 + processOutput("", { exitCode: ChildProcessSpawner.ExitCode(2) }),
2085 + );
2086 + if (input.command !== "fj")
2087 + return Effect.fail(
2088 + new VcsProcessSpawnError({
2089 + operation: input.operation,
2090 + command: input.command,
2091 + cwd: input.cwd,
2092 + cause: new Error("not installed"),
2093 + }),
2094 + );
2095 + if (input.args[0] === "version") return Effect.succeed(processOutput("fj v0.7.0"));
2096 + const host = input.args[input.args.indexOf("--host") + 1] ?? "";
2097 + return Effect.succeed(
2098 + host.startsWith("http://")
2099 + ? processOutput("currently signed into maria@forgejo.local:3000")
2100 + : processOutput("", {
2101 + exitCode: ChildProcessSpawner.ExitCode(1),
2102 + stderr: `Error: error sending request for url (${host}/api/v1/user?)\nCaused by:\n 0: client error (Connect)\n 1: received corrupt message of type InvalidContentType`,
2103 + }),
2104 + );
2105 + },
2106 + },
2107 + }),
2108 + ),
2109 + Effect.provideService(HostProcess.HomeDirectory, "/home/maria"),
2110 + ),
2111 +);
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.ts
+12 -5
@@ -115,11 +115,18 @@ export const makeDiscovery = Effect.gen(function* () {
115 account: login.user,
116 host: ForgejoCli.parseForgejoRemote(login.url)?.host,
117 })
118 - : providerAuth({
119 - status: "unauthenticated",
120 - detail:
121 - "Authenticate this server with `fj --host <server-url> auth add-token`.",
122 - }),
118 + : // fj prints this for transport failures (TLS, connect, DNS), never for a rejected token.
119 + login && result.stderr.includes("error sending request for url")
120 + ? providerAuth({
121 + status: "unknown",
122 + detail: `Could not reach ${login.url} to verify the fj login.`,
123 + host: ForgejoCli.parseForgejoRemote(login.url)?.host,
124 + })
125 + : providerAuth({
126 + status: "unauthenticated",
127 + detail:
128 + "Authenticate this server with `fj --host <server-url> auth add-token`.",
129 + }),
130 },
131 });
132 if (fj.status === "available" && (login || Result.isFailure(credentials))) {