Repository navigation
basou: Keep the path out of decision capture's and review record's error for a --file they cannot read - #354
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
basou decision captureandbasou review recordprintedInput 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)inpackages/cli/src/lib/input-file.tswithbasou note, which already said this:--file names a file that does not exist--file names a directory, not a fileCould not read the file --file namesThe native error stays on
cause, so--verbose(orBASOU_DEBUG=1) addsCaused by: <code>. Exit code, what is written (nothing, on a failure) and how a relative--fileis 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.-v: a missing file (absolute and relative), a directory, achmod 000file,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.Errorwhose code-vprints, and that a relative--fileis read from the working directory rather than the workspace root. 11 mutations against the final code are caught.