@devries-cameron20 / t3code-1 / commits / 0902adcc03
Fork 0

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

fix(forgejo): tea API failures keep Gitea's reason (#32244)

Julius Marminge committed Nov 12, 2026 at 23:58 UTC 0902adcc03de7c96ac8c0973e8f897c57bd75d73
2 files changed +69 -2
packages/source-control-forgejo/src/server/ForgejoCli.ts
+8 -2
@@ -727,7 +727,8 @@ export const make = Effect.gen(function* () {
727 });
728 // tea reports HTTP failures with exit code zero; use its response status.
729 const status = Number(/^HTTP\/\S+ (\d{3})/m.exec(result.stderr)?.[1]);
730 - if (!status || status >= 400)
730 + if (!status || status >= 400) {
731 + const body = result.stdout.trim();
732 return yield* new ForgejoCliError({
733 command: "tea",
734 cwd: input.cwd,
@@ -748,8 +749,13 @@ export const make = Effect.gen(function* () {
749 ? "Forgejo repository or pull request was not found."
750 : status === 429
751 ? "Forgejo API rate limit exceeded."
751 - : `Forgejo API request failed${status ? ` (HTTP ${status})` : " without an HTTP status"}.`,
752 + : !status
753 + ? "Forgejo API request failed without an HTTP status."
754 + : body
755 + ? `Forgejo API request failed (HTTP ${status}): ${body}`
756 + : `Forgejo API request failed (HTTP ${status}).`,
757 });
758 + }
759 return result;
760 });
761 return ForgejoCli.of({ execute, listLogins, getAccount, resolveRepository, api });
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
+61
@@ -1437,6 +1437,67 @@ it.effect("rejects HTTP failures even when tea exits successfully", () =>
1437 ),
1438 );
1439
1440 +it.effect("keeps Gitea's failure reason when tea reports an HTTP error", () =>
1441 + Effect.gen(function* () {
1442 + const cli = yield* ForgejoCli.make;
1443 + const result = yield* cli
1444 + .api({
1445 + cwd: "/repo",
1446 + repository: "http://forgejo.local:3000/maria/project",
1447 + path: "repos/maria/project/pulls/1/merge",
1448 + method: "POST",
1449 + body: { Do: "merge", delete_branch_after_merge: true },
1450 + })
1451 + .pipe(Effect.result);
1452 + assert.strictEqual(result._tag, "Failure");
1453 + if (result._tag === "Failure") {
1454 + assert.include(result.failure.detail, "405");
1455 + assert.include(result.failure.detail, "The head branch is behind the base branch");
1456 + }
1457 + }).pipe(
1458 + Effect.provideService(
1459 + FileSystem.FileSystem,
1460 + FileSystem.makeNoop({
1461 + exists: () => Effect.succeed(false),
1462 + }),
1463 + ),
1464 + Effect.provideService(
1465 + HttpClient.HttpClient,
1466 + HttpClient.make(() => {
1467 + throw new Error("tea must handle its own HTTP request");
1468 + }),
1469 + ),
1470 + Effect.provide(
1471 + TestSourceControlHost.layer({
1472 + process: {
1473 + run: (input) =>
1474 + Effect.succeed(
1475 + input.args[0] === "login"
1476 + ? processOutput(
1477 + encodeJson([
1478 + {
1479 + name: "work",
1480 + url: "http://forgejo.local:3000",
1481 + ssh_host: "forgejo.local",
1482 + user: "maria",
1483 + default: "true",
1484 + },
1485 + ]),
1486 + )
1487 + : processOutput(
1488 + '{"message":"The head branch is behind the base branch","url":"http://forgejo.local:3000/api/swagger"}',
1489 + {
1490 + stderr:
1491 + "HTTP/1.1 405 Method Not Allowed\nContent-Type: application/json;charset=utf-8\n",
1492 + },
1493 + ),
1494 + ),
1495 + },
1496 + }),
1497 + ),
1498 + ),
1499 +);
1500 +
1501 it.effect("routes mounted Forgejo repositories without repeating the mount in API paths", () =>
1502 Effect.gen(function* () {
1503 const cli = yield* ForgejoCli.make;