Skip to content

basou: Keep the path out of decision capture's and review record's error for a --file they cannot read - #354

Merged
takashi-matsuyama merged 2 commits into
mainfrom
cli/pathless-input-file-errors
Oct 15, 2026
Merged

takashi-matsuyama merged 2 commits into
mainfrom
cli/pathless-input-file-errors

Conversation

@takashi-matsuyama

Copy link
Copy Markdown
Member

What

basou decision capture and basou review record printed Input file not found: <path as given> for a missing --file, and passed on Node's own error for most other read failures (no read permission, say), whose message names the path. A path the caller gives can be absolute, so both broke the CLI's pathless error contract.

They now share readInputFileText(flag, path) in packages/cli/src/lib/input-file.ts with basou note, which already said this:

  • --file names a file that does not exist
  • --file names a directory, not a file
  • Could not read the file --file names

The native error stays on cause, so --verbose (or BASOU_DEBUG=1) adds Caused by: <code>. Exit code, what is written (nothing, on a failure) and how a relative --file is resolved are unchanged.

Verification

  • pnpm test (core 2750, sdk 65, cli 1538), pnpm typecheck, pnpm lint, pnpm lint:lang, pnpm lint:paths: all exit 0.
  • A built CLI, for each of the three commands, with and without -v: a missing file (absolute and relative), a directory, a chmod 000 file, ENOTDIR, a symlink loop, a broken symlink and a 300-character name print no path and no native message, exit 1, and write no session.
  • Tests pin the three messages, that the cause is an Error whose code -v prints, and that a relative --file is read from the working directory rather than the workspace root. 11 mutations against the final code are caught.

…ror for a --file they cannot read

"Input file not found: <path>" printed the path as given, which can be
absolute, and any other read failure (no read permission, say) passed on
Node's own message, path included. Both broke the CLI's pathless error
contract.

The read is now one function, readInputFileText in lib/input-file.ts, which
note already used in effect: a fixed message naming the flag (does not
exist / is a directory / could not be read), with the cause kept for
--verbose. decision capture, review record and note share it.
…decision capture and review record

The cause readInputFileText attaches must be an Error, as --verbose prints a
code only from one; a test now checks that, and that decision capture with -v
prints "Caused by: ENOENT" after the message. Tests also pin that a relative
--file is read from the working directory, not the workspace root, for
decision capture and review record.

The CHANGELOG now says most other read failures named the path: a
directory's EISDIR message never did.
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