Fix: Improve error handling in readConfig() to distinguish read vs parse errors#45
Open
hobostay wants to merge 1 commit into
Open
Fix: Improve error handling in readConfig() to distinguish read vs parse errors#45hobostay wants to merge 1 commit into
hobostay wants to merge 1 commit into
Conversation
…rse errors Previously, readConfig() would report all errors as "failed to parse", even if the actual error was a file system issue (permission denied, file is a directory, etc.) during readFileSync(). This change splits the error handling into two stages: 1. First, read the file content - errors are reported as "failed to read" 2. Then, parse the JSON - errors are reported as "failed to parse" This provides more accurate error messages to help users diagnose configuration issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@hobostay is attempting to deploy a commit to the Yury Selivanov's projects Team on Vercel. A member of the Team first needs to authorize it. |
lars20070
reviewed
May 4, 2026
| process.stderr.write( | ||
| `Error: failed to read config ${configPath}: ${(err as Error).message}\n`, | ||
| ); | ||
| process.exit(1); |
Contributor
There was a problem hiding this comment.
Can you throw an error instead of exit in order to be consistent with getLlmKey below?
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.
Problem
The
readConfig()function insrc/config.tshad imprecise error handling. All errors were reported as "failed to parse config", even when the actual error was a file system issue (e.g., permission denied, file is a directory, I/O error) that occurred duringreadFileSync().This made it difficult for users to diagnose configuration issues - a permission problem would be reported as a parse error, leading to confusion.
Solution
Split the error handling into two distinct stages:
readFileSync(). Any errors at this stage (file system issues) are now reported as "failed to read config".Changes
src/config.ts: ModifiedreadConfig()to separate file reading from JSON parsingTesting
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com