Skip to content

fix: log statSync failures in findDbPath instead of silently swallowing them#1861

Closed
carlos-alm wants to merge 1 commit into
fix/issue-1749-connection-busytimeout-regex-dedupefrom
fix/issue-1750-finddbpath-swallowed-errors
Closed

fix: log statSync failures in findDbPath instead of silently swallowing them#1861
carlos-alm wants to merge 1 commit into
fix/issue-1749-connection-busytimeout-regex-dedupefrom
fix/issue-1750-finddbpath-swallowed-errors

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

  • resolveCustomDbPath's catch block silently swallowed all fs.statSync errors, unlike every other catch block in this file (18 of them), leaving no diagnostic trail for a genuine unexpected error (EACCES, symlink loop) vs. the expected "not found yet" case.
  • Added a debug(...) call matching the file's existing convention. Behavior unchanged — still falls through to treat the path as not-yet-existing.

Closes #1750

Test plan

  • npm test — full suite green (3490 passed, 0 failed)
  • npm run lint — clean

Stacked on #1860 (base branch fix/issue-1749-connection-busytimeout-regex-dedupe) — only the connection.ts diff is this issue's change.

…ng them

The catch block in resolveCustomDbPath (part of the findDbPath flow) caught
all fs.statSync errors — including unexpected ones like EACCES or symlink
loops — indistinguishably from the expected "path doesn't exist yet" case,
leaving no diagnostic trail. Add a debug() call matching this file's
existing convention (18 other catch blocks already do this).

Fixes #1750

Impact: 1 functions changed, 68 affected
@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a silent error swallow in resolveCustomDbPath by adding a debug(...) call when fs.statSync throws, consistent with how every other catch block in connection.ts handles unexpected errors.

  • The single changed catch block now captures the thrown error as e and logs it via debug + toErrorMessage, matching the existing convention throughout the file.
  • Behavior is unchanged: the path is still returned as-is after any statSync failure, preserving the "path doesn't exist yet" fallback.

Confidence Score: 5/5

The change is safe to merge — it adds a single diagnostic log line to an existing catch block without altering control flow or error handling behavior.

The diff is a one-liner addition of a debug(...) call that was already the established pattern in 18 other catch blocks in the same file. Both debug and toErrorMessage are already imported; the error variable binding from catch {} to catch (e) is the only structural change. The fallback return path is untouched.

No files require special attention.

Important Files Changed

Filename Overview
src/db/connection.ts Adds a debug(...) log in the resolveCustomDbPath catch block to surface statSync errors, matching the pattern used in 18 other catch blocks in the same file. Behavior is otherwise unchanged.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[resolveCustomDbPath called] --> B[path.resolve customPath]
    B --> C[fs.statSync resolved]
    C -->|success| D{isDirectory?}
    D -->|yes, basename === .codegraph| E[return resolved/graph.db]
    D -->|yes, other| F[return resolved/.codegraph/graph.db]
    D -->|no - is a file| G[return resolved]
    C -->|throws| H["BEFORE: silent catch {}"]
    C -->|throws| I["AFTER: debug log + fall through"]
    H --> G
    I --> G
    style H fill:#f88,stroke:#c00
    style I fill:#8f8,stroke:#080
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[resolveCustomDbPath called] --> B[path.resolve customPath]
    B --> C[fs.statSync resolved]
    C -->|success| D{isDirectory?}
    D -->|yes, basename === .codegraph| E[return resolved/graph.db]
    D -->|yes, other| F[return resolved/.codegraph/graph.db]
    D -->|no - is a file| G[return resolved]
    C -->|throws| H["BEFORE: silent catch {}"]
    C -->|throws| I["AFTER: debug log + fall through"]
    H --> G
    I --> G
    style H fill:#f88,stroke:#c00
    style I fill:#8f8,stroke:#080
Loading

Reviews (1): Last reviewed commit: "fix: log statSync failures in findDbPath..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Codegraph Impact Analysis

1 functions changed68 callers affected across 40 files

  • resolveCustomDbPath in src/db/connection.ts:270 (71 transitive callers)

@carlos-alm carlos-alm deleted the branch fix/issue-1749-connection-busytimeout-regex-dedupe July 6, 2026 17:01
@carlos-alm carlos-alm closed this Jul 6, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 6, 2026
@carlos-alm

Copy link
Copy Markdown
Contributor Author

Recreated as #1903 — this PR was inadvertently closed when its stacked base branch was deleted after #1899 merged. Continuing there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant