fix(domain): report target read-permission denials as access_denied
Opening a target the current user cannot read returned `target_unavailable`, the same code as a missing target, although the reason named EACCES. Clients that branch on the error code could not choose read-access recovery, contrary to the boundary contract that separates host permission denial from unavailable targets. A BinaryTargetError whose cause is an OS EACCES or EPERM now records that system code and projects as `access_denied` with `system_code`, the filesystem-read boundary, and read-access remediation, while keeping its specific reason and path. This covers target files, app bundle paths and Info.plist reads, and selected plist reads, since every site passes the OS error as the cause. Fixes #1188 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e6abaefbbc
commit
d0ff57a45c
@@ -439,6 +439,42 @@ describe("analysis error projection: caller contract", () => {
|
||||
expect(JSON.stringify(projected)).not.toContain("secret-token");
|
||||
});
|
||||
|
||||
it.each(["EACCES", "EPERM"] as const)(
|
||||
"reports a target the host refused to read (%s) as access_denied",
|
||||
(systemCode) => {
|
||||
const denied = Object.assign(new Error("denied"), { code: systemCode });
|
||||
const reason = `permission denied while reading target: ${systemCode}`;
|
||||
expect(
|
||||
projectAnalysisError(
|
||||
new BinaryTargetError("/local/targets/app", reason, {
|
||||
cause: denied,
|
||||
}),
|
||||
),
|
||||
).toMatchObject({
|
||||
code: "access_denied",
|
||||
category: "unavailable",
|
||||
retryable: false,
|
||||
remediation: {
|
||||
action:
|
||||
"Check the current process's read access to the selected path. Retry with a readable local file.",
|
||||
},
|
||||
details: {
|
||||
path: "/local/targets/app",
|
||||
reason,
|
||||
system_code: systemCode,
|
||||
boundary: "filesystem-read",
|
||||
},
|
||||
});
|
||||
expect(
|
||||
projectAnalysisError(
|
||||
new BinaryTargetError("/local/targets/app", "missing", {
|
||||
cause: Object.assign(new Error("missing"), { code: "ENOENT" }),
|
||||
}),
|
||||
),
|
||||
).toMatchObject({ code: "target_unavailable" });
|
||||
},
|
||||
);
|
||||
|
||||
it("uses explicit capability recovery while retaining the constraint", () => {
|
||||
const projected = projectAnalysisError(
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
|
||||
Reference in New Issue
Block a user