Skip to content

Commit 0ad4e0e

Browse files
Ark0Nclaude
andcommitted
fix: correct resolveCasePath priority order and suppress JSON parse warnings
- resolveCasePath now checks linked cases first (matching original behavior of /api/cases/:name and /api/cases/:name/fix-plan handlers) - readLinkedCases only warns on real I/O errors, not JSON parse errors (SyntaxError has no .code property, so check for .code existence first) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6bc403d commit 0ad4e0e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/web/routes/case-routes.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ async function readLinkedCases(): Promise<Record<string, string>> {
2525
try {
2626
return JSON.parse(await fs.readFile(LINKED_CASES_FILE, 'utf-8'));
2727
} catch (err) {
28-
if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {
28+
// Only warn on real I/O errors, not ENOENT (file missing) or SyntaxError (corrupted JSON)
29+
if ((err as NodeJS.ErrnoException).code && (err as NodeJS.ErrnoException).code !== 'ENOENT') {
2930
console.warn('[Server] Failed to read linked cases:', err);
3031
}
3132
return {};
3233
}
3334
}
3435

35-
/** Resolve a case name to its directory path, checking linked cases if not in CASES_DIR. */
36+
/** Resolve a case name to its directory path, checking linked cases first, then CASES_DIR. */
3637
async function resolveCasePath(name: string): Promise<string> {
37-
const casePath = join(CASES_DIR, name);
38-
if (existsSync(casePath)) return casePath;
3938
const linkedCases = await readLinkedCases();
40-
return linkedCases[name] ?? casePath;
39+
if (linkedCases[name]) return linkedCases[name];
40+
return join(CASES_DIR, name);
4141
}
4242

4343
export function registerCaseRoutes(app: FastifyInstance, ctx: EventPort & ConfigPort): void {

0 commit comments

Comments
 (0)