Merge pull request #1074 from morluto/fix/evidence-file-missing

fix(evidence): report missing evidence files instead of permission advice
This commit is contained in:
Kaoru0822
2026-10-08 07:22:31 -07:00
committed by GitHub
6 changed files with 92 additions and 16 deletions
+9 -3
View File
@@ -162,8 +162,7 @@ export const analysisErrorUserMessage = (error: AnalysisError): string => {
: `Evidence ${error.evidenceId} does not match the requested reference (${error.reason}). Check the expected and actual identity in the diagnostic details.`;
if (error instanceof EvidenceIntegrityError)
return "Evidence is invalid or has changed. Recreate or re-import it, then try again.";
if (error instanceof EvidenceFileError)
return evidenceFileMessage(error.reason);
if (error instanceof EvidenceFileError) return evidenceFileMessage(error);
if (error instanceof UnknownRegistryError && error.reason === "not-found")
return "The requested residual unknown does not exist in this session. Check the unknown_id and try again.";
if (error instanceof UnknownRegistryError)
@@ -258,7 +257,14 @@ const artifactMessage = (reason: ArtifactOperationError["reason"]): string => {
return "Artifact could not be read or written. Check file access and try again.";
};
const evidenceFileMessage = (reason: EvidenceFileError["reason"]): string => {
const evidenceFileMessage = ({
operation,
reason,
}: EvidenceFileError): string => {
if (reason === "missing")
return operation === "read"
? "Evidence file does not exist at the selected path. Check the path and try again."
: "Evidence output directory does not exist. Choose an existing directory and try again.";
if (reason === "not-file")
return "Evidence path does not point to a regular file. Choose a file and try again.";
if (reason === "exists")
+5 -1
View File
@@ -259,7 +259,11 @@ const artifactStateErrorDetails = (
};
if (error instanceof UnknownRegistryError) return { reason: error.reason };
if (error instanceof EvidenceFileError)
return { operation: error.operation, reason: error.reason };
return {
operation: error.operation,
reason: error.reason,
...(error.path === undefined ? {} : { path: error.path }),
};
return undefined;
};
+6 -2
View File
@@ -25,11 +25,15 @@ export class EvidenceReferenceError extends EvidenceIntegrityError {
export class EvidenceFileError extends AnalysisError {
readonly _tag = "EvidenceFileError";
/** Caller-selected path that failed, resolved against the working directory. */
readonly path: string | undefined;
constructor(
readonly operation: "read" | "write",
readonly reason: "not-file" | "exists" | "invalid-json" | "io",
options?: ErrorOptions,
readonly reason: "not-file" | "exists" | "invalid-json" | "missing" | "io",
options?: ErrorOptions & { readonly path?: string },
) {
super(`Evidence bundle ${operation} failed: ${reason}`, options);
this.path = options?.path;
}
}