fix: distinguish evidence tree lookup failures
This commit is contained in:
@@ -278,8 +278,10 @@ export class GitWorkspaceRepository {
|
|||||||
);
|
);
|
||||||
return stdout;
|
return stdout;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (invalidObjectMessage && typeof error === "object" && error !== null
|
const stderr = typeof error === "object" && error !== null && "stderr" in error
|
||||||
&& "code" in error && typeof error.code === "number") {
|
&& typeof error.stderr === "string" ? error.stderr : "";
|
||||||
|
if (invalidObjectMessage
|
||||||
|
&& /^fatal: path '[^']+' does not exist in '[0-9a-f]{40}'\s*$/u.test(stderr)) {
|
||||||
throw new WorkspaceRegistryError("workspace_invalid", invalidObjectMessage);
|
throw new WorkspaceRegistryError("workspace_invalid", invalidObjectMessage);
|
||||||
}
|
}
|
||||||
throw this.sanitizeGitError(error);
|
throw this.sanitizeGitError(error);
|
||||||
|
|||||||
@@ -142,6 +142,18 @@ test("redacts Git failures while checking an Evidence tree", async () => {
|
|||||||
expect((error as Error).message).not.toContain(fixture.root);
|
expect((error as Error).message).not.toContain(fixture.root);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("classifies repository corruption as unavailable rather than invalid Evidence", async () => {
|
||||||
|
const fixture = await temporaryRemote();
|
||||||
|
const repository = new GitWorkspaceRepository(config(join(fixture.root, "registry"), fixture.remote));
|
||||||
|
await repository.bootstrap();
|
||||||
|
rmSync(join(repository.repoPath, ".git", "objects"), { recursive: true, force: true });
|
||||||
|
|
||||||
|
await expect(repository.assertTreeAtRevision(
|
||||||
|
fixture.initialCommit,
|
||||||
|
"workspace-content/research/evidence",
|
||||||
|
)).rejects.toMatchObject({ code: "git_unavailable", message: "Workspace Git operation failed" });
|
||||||
|
});
|
||||||
|
|
||||||
test("binds Evidence tree validation to old and new content-only commits", async () => {
|
test("binds Evidence tree validation to old and new content-only commits", async () => {
|
||||||
const fixture = await temporaryRemote();
|
const fixture = await temporaryRemote();
|
||||||
const repository = new GitWorkspaceRepository(config(join(fixture.root, "registry"), fixture.remote));
|
const repository = new GitWorkspaceRepository(config(join(fixture.root, "registry"), fixture.remote));
|
||||||
|
|||||||
Reference in New Issue
Block a user