Files
PaperClipAI/server/src/__tests__/git-expiration-auth-fallback.test.ts
T
Devin FoleyandPaperclip 5555817c2b fix(server): let Git expiration verify public commits without a run identity (#16621)
Git expiration created its auth provider with only the issue ID; with a managed GitHub connection that provider throws outside a run ("No managed GitHub identity is available for this run"), so every upstream commit proof failed and was logged as inspection_failed. Expiration now falls back to anonymous access when the provider throws: public repositories verify, private ones stay kept. Upstream verification failures are reported as upstream_commit_unverified, and a managed checkout whose upstream cannot be reached or authenticated as managed_checkout_upstream_unavailable; local proof-store failures keep their own error.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-16 20:54:30 -07:00

25 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { gitExpirationSkipReason, withAnonymousGitFallback } from "../services/git-workspace-expiration.js";
import { GitCacheRestorationFailure } from "../services/git-workspace-restoration.js";
describe("Git expiration upstream access", () => {
it("falls back to anonymous access when the company identity cannot be resolved", async () => {
const unavailable = withAnonymousGitFallback(async () => {
throw new Error("No managed GitHub identity is available for this run");
});
await expect(unavailable("https://github.com/example/public")).resolves.toBeNull();
});
it("passes resolved credentials through unchanged", async () => {
const credential = { env: { GIT_ASKPASS: "/bin/true" }, configArgs: ["-c", "credential.helper="] };
const resolved = withAnonymousGitFallback(async () => credential);
await expect(resolved("https://github.com/example/private")).resolves.toBe(credential);
});
it("names upstream verification failures instead of reporting them as inspection failures", () => {
expect(gitExpirationSkipReason(new GitCacheRestorationFailure())).toBe("upstream_commit_unverified");
expect(gitExpirationSkipReason(new Error("unpushed_managed_checkout"))).toBe("unpushed_managed_checkout");
expect(gitExpirationSkipReason(new Error("spawn git ENOENT"))).toBe("inspection_failed");
});
});