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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user