fix: filter invalid session IDs in listMetadata to prevent downstream crashes

listMetadata() now validates filenames against VALID_SESSION_ID regex
before returning them, preventing readMetadataRaw() from throwing on
unexpected files in the sessions directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Prateek 2026-02-14 06:30:13 +05:30
parent 660b8bb13d
commit f2e0ac1867
1 changed files with 1 additions and 0 deletions

View File

@ -192,6 +192,7 @@ export function listMetadata(dataDir: string): SessionId[] {
return readdirSync(dir).filter((name) => {
if (name === "archive" || name.startsWith(".")) return false;
if (!VALID_SESSION_ID.test(name)) return false;
try {
return statSync(join(dir, name)).isFile();
} catch {