Skip to content

Commit 9879a03

Browse files
tyaginidhiclaude
andcommitted
validate-legacy-compatibility: detect CLAUDE.md presence with lstat, not existsSync
Address review feedback on #206: existsSync follows symlinks, so a dangling CLAUDE.md symlink (link to a missing target) reported as absent and skipped the very regular-file guard meant to reject symlinks. Switch the presence test to lstatSync (non-following) and skip only on ENOENT, so any committed symlink — resolving or dangling — reaches assertRegularFile and fails the check. Verified: a dangling CLAUDE.md symlink now fails (previously passed); clean tree still passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c54ab08 commit 9879a03

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

scripts/validate-legacy-compatibility.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,21 @@ function assertTextMirror(mirrorPath, sourcePath) {
7272

7373
// Guard CLAUDE.md only where it exists (root + some plugins); a directory with no
7474
// CLAUDE.md is intentional (e.g. code-apps, mcp-apps) and must not fail the check.
75+
// Use lstat (not existsSync) for the presence test: existsSync follows symlinks, so
76+
// a DANGLING CLAUDE.md symlink would look absent and skip the very guard meant to
77+
// reject symlinks. lstat sees the link itself; only a true ENOENT means "no file".
7578
function checkClaudeMirror(directory) {
7679
const claudePath = path.join(directory, 'CLAUDE.md');
7780
const agentsPath = path.join(directory, 'AGENTS.md');
78-
if (!fs.existsSync(claudePath)) {
79-
return;
81+
try {
82+
fs.lstatSync(claudePath);
83+
} catch (error) {
84+
if (error.code === 'ENOENT') {
85+
return;
86+
}
87+
throw error;
8088
}
81-
const label = normalizeRelative(path.relative(ROOT, claudePath)) || 'CLAUDE.md';
89+
const label = normalizeRelative(path.relative(ROOT, claudePath));
8290
check(label, () => {
8391
assert.ok(fs.existsSync(agentsPath), `missing sibling AGENTS.md for ${label}`);
8492
assertTextMirror(claudePath, agentsPath);

0 commit comments

Comments
 (0)