Skip to content

Commit c7cdaa7

Browse files
committed
fix: address review feedback on CSV validator extension
- Surface CSV parse errors visibly instead of silently swallowing (no Layer 2c schema validator exists yet to catch these) - Add explanatory comments for the !VERBOSE logging pattern (non-verbose prints file headers only when issues found) - Add verbose-mode diagnostics for extensionless path handling ([SKIP] when nothing exists, [OK-DIR] for valid directories)
1 parent e2acf1e commit c7cdaa7

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tools/validate-file-refs.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,15 @@ function extractCsvRefs(filePath, content) {
303303
skip_empty_lines: true,
304304
relax_column_count: true,
305305
});
306-
} catch {
307-
return refs; // Skip unparseable CSV
306+
} catch (error) {
307+
// No CSV schema validator exists yet (planned as Layer 2c) — surface parse errors visibly.
308+
// YAML equivalent (line ~198) defers to validate-agent-schema.js; CSV has no such fallback.
309+
const rel = path.relative(PROJECT_ROOT, filePath);
310+
console.error(` [CSV-PARSE-ERROR] ${rel}: ${error.message}`);
311+
if (process.env.GITHUB_ACTIONS) {
312+
console.log(`::warning file=${rel},line=1::${escapeAnnotation(`CSV parse error: ${error.message}`)}`);
313+
}
314+
return refs;
308315
}
309316

310317
// Only process if workflow-file column exists
@@ -421,6 +428,8 @@ if (require.main === module) {
421428
// Resolve and check
422429
const broken = [];
423430

431+
// Verbose mode: print file header for every file with refs (so [OK] lines have context).
432+
// Non-verbose mode prints the header later, only when issues are found (see below).
424433
if (VERBOSE && refs.length > 0) {
425434
console.log(`\n${relativePath}`);
426435
}
@@ -430,10 +439,18 @@ if (require.main === module) {
430439
const resolved = resolveRef(ref);
431440

432441
if (resolved && !fs.existsSync(resolved)) {
433-
// For paths without extensions, also check if it's a directory
442+
// Extensionless paths may be directory references or partial templates.
443+
// If the path has no extension, check whether it exists as a directory.
444+
// Flag it if nothing exists at all — likely a real broken reference.
434445
const hasExt = path.extname(resolved) !== '';
435446
if (!hasExt) {
436-
// Could be a directory reference — skip if not clearly a file
447+
if (!fs.existsSync(resolved)) {
448+
if (VERBOSE) {
449+
console.log(` [SKIP] ${ref.raw} (no extension, target not found)`);
450+
}
451+
} else if (VERBOSE) {
452+
console.log(` [OK-DIR] ${ref.raw}`);
453+
}
437454
continue;
438455
}
439456
broken.push({ ref, resolved: path.relative(PROJECT_ROOT, resolved) });
@@ -453,6 +470,8 @@ if (require.main === module) {
453470
// Report issues for this file
454471
if (broken.length > 0 || leaks.length > 0) {
455472
filesWithIssues++;
473+
// Non-verbose: print file header only when reporting issues.
474+
// Verbose mode already printed it above (for every file with refs).
456475
if (!VERBOSE) {
457476
console.log(`\n${relativePath}`);
458477
}

0 commit comments

Comments
 (0)