mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-09 11:17:57 +02:00
fix(scripts): surface unreadable AGENTS.md in legacy codex sync detection
hasMarkerBlock previously swallowed every read/open error and returned false, so an unreadable AGENTS.md (EACCES, EMFILE, EISDIR, ...) made detectLegacyCodexSync report a clean Codex home instead of an indeterminate inspection result. The fallback path could then skip legacy cleanup and exit 0 with legacy artifacts still in place. Restrict the catch to ENOENT (a missing file legitimately means no marker block) and rethrow everything else. detectLegacyCodexSync already propagates from hasMarkerBlock, so callers now see the actual inspection error instead of a misleading 'no marker'. Regression test in tests/lib/codex-legacy-sync.test.js makes a detectLegacyCodexSync call against an unreadable AGENTS.md and asserts that it throws something other than ENOENT, plus a sanity check that a missing AGENTS.md still reads as no-marker.
This commit is contained in:
@@ -483,8 +483,15 @@ function hasMarkerBlock(codexHome) {
|
||||
const stripped = stripMarkerBlock(snapshot.content);
|
||||
return stripped !== snapshot.content;
|
||||
}
|
||||
} catch (_error) {
|
||||
// Non-regular or unreadable AGENTS.md is not a clean marker signal.
|
||||
} catch (error) {
|
||||
// Only ENOENT means "no AGENTS.md" → no marker. Any other error
|
||||
// (EACCES, EMFILE, EISDIR, symlink-ELOOP, ...) is an indeterminate
|
||||
// inspection result and must propagate so callers do not read it as
|
||||
// "clean home". Throwing here is intentional per the repo coding
|
||||
// guideline: "Always handle errors explicitly at every level and never
|
||||
// silently swallow errors."
|
||||
if (error && error.code === 'ENOENT') return false;
|
||||
throw error;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user