fix(coding-agent): report edit access failures correctly (#3955)

* fix(coding-agent): report edit access failures correctly closes #3894

- classify edit and edit-preview access errors by errno
- add regressions for missing, permission, and fallback cases
- document the fix in the coding-agent changelog

* chore: get rid of CHANGELOG.md entry

* refactor(coding-agent): apply review suggestions - use single error msg

* refactor(coding-agent): clean up test cases
This commit is contained in:
Ramiz Wachtler
2026-04-30 12:31:29 +02:00
committed by GitHub
parent 0dd11898ad
commit 43ee9b77ed
3 changed files with 69 additions and 5 deletions

View File

@@ -412,8 +412,9 @@ export async function computeEditsDiff(
// Check if file exists and is readable
try {
await access(absolutePath, constants.R_OK);
} catch {
return { error: `File not found: ${path}` };
} catch (error: unknown) {
const errorMessage = error instanceof Error && "code" in error ? `Error code: ${error.code}` : String(error);
return { error: `Could not write file: ${path}. ${errorMessage}.` };
}
// Read the file

View File

@@ -341,11 +341,13 @@ export function createEditToolDefinition(
// Check if file exists.
try {
await ops.access(absolutePath);
} catch {
} catch (error: unknown) {
const errorMessage =
error instanceof Error && "code" in error ? `Error code: ${error.code}` : String(error);
if (signal) {
signal.removeEventListener("abort", onAbort);
}
reject(new Error(`File not found: ${path}`));
reject(new Error(`Could not write file: ${path}. ${errorMessage}.`));
return;
}