Skip to content

feat: scrub home-dir paths from user-facing CLI error messages#6

Merged
askalf merged 1 commit into
masterfrom
feat/error-sanitization
Apr 23, 2026
Merged

feat: scrub home-dir paths from user-facing CLI error messages#6
askalf merged 1 commit into
masterfrom
feat/error-sanitization

Conversation

@askalf

@askalf askalf commented Apr 23, 2026

Copy link
Copy Markdown
Owner

Summary

A Playwright ENOENT message, an LLM 5xx that echoes a cached path, a parse error on a config file — every one of those could leak C:\Users\alice\... or /home/alice/... into a bug report pasted to an issue. Not an exploit, but bad hygiene and fixable cheaply.

Change

Added safeErrorMessage(err) in cli.ts. Pipes every user-facing error through scrubPath (home dir → ~, backslashes → forward slashes) before printing. Applied at the two CLI error paths: parse-time (parseArgs throws) and runtime (runAgent / runDoctor throws).

Library consumers of runAgent still get raw errors — the trust boundary is the CLI, not the library.

Test plan

  • npm run build — clean under strict: true
  • npm test — 164 pass (up from 159), 0 fail
  • 5 new assertions in test/cli-errors.test.mjs: Windows home scrubbed, Unix home scrubbed, non-Error throws handled, non-path content preserved unchanged, backslashes normalized on Windows

A Playwright ENOENT, an LLM 5xx that echoes a cached path back, a parse
error on a config file — every one of those could leak the user's home
directory into a paste-able bug report. Not an exploit, but bad hygiene
and fixable cheaply.

Added `safeErrorMessage(err)` in cli.ts, exported for library reuse.
Pipes every error through `scrubPath` (which replaces the home dir with
`~` and normalizes backslashes to forward slashes) before user-facing
output. Applied at the two places cli.ts converts errors to text:
parse-time (parseArgs throws) and runtime (runAgent or runDoctor throws).

Library users calling `runAgent` still get raw errors for debugging —
the trust boundary is the CLI, not the library.

5 new test assertions (164 total, up from 159): Windows home dir
scrubbed, Unix home dir scrubbed, non-Error values handled, non-path
content preserved unchanged, backslashes normalized on Windows.
@askalf askalf enabled auto-merge (squash) April 23, 2026 01:13
@askalf askalf merged commit ac84e3b into master Apr 23, 2026
4 checks passed
@askalf askalf deleted the feat/error-sanitization branch April 23, 2026 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant