Skip to content

db/connection.ts: findDbPath silently swallows all fs.statSync errors (not just ENOENT) #1750

Description

@carlos-alm

GAUNTLET (Titan phase 15 audit, rule 10) flagged a comment-only catch block in findDbPath (lines ~277-279) that silently swallows all fs.statSync errors, not just the expected "path doesn't exist yet" case:

try {
  if (fs.statSync(resolved).isDirectory()) { ... }
} catch {
  // Path doesn't exist yet — return as-is (e.g. a future custom DB path).
}

Every other catch block in this file (18 of them) calls debug(...) with the caught error; this one doesn't, so a genuine unexpected error (e.g. EACCES, a symlink loop) is indistinguishable from the expected "not found yet" case and leaves no diagnostic trail.

Out of scope for phase 15 (narrowly scoped to the openReadonlyWithNative leak-ordering fix + engine-resolution dedup per sync.json's phase-15 label).

Recommendation: add a debug(...) call matching the file's existing convention, e.g. debug(\findDbPath: statSync failed for ${resolved}, treating as non-existent: ${toErrorMessage(e)}`)`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions