fix: 6 verified bugs cherry-picked from PR #9#14
Conversation
Each bug was independently reproduced before fixing:
- api-key-validation: Anthropic 429/5xx incorrectly resolved as valid key
- api-key-validation: no HTTP timeout, requests hang forever on unreachable providers
- setup-window: remote debug port 9222 always enabled (now opt-in via SIDECAR_DEBUG_PORT)
- ipc-setup: get-api-keys handler has no error handling, saveApiKey failures ignored
- cli: --key=value syntax parsed as {"model=gemini": true} instead of {"model": "gemini"}
- pre-push hook: test failures don't block push (exits 0 due to npm audit fallback)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Addresses code review findings: - 4 tests for --key=value CLI parsing (equals syntax, numeric, nested slash, space-separated compat) - 2 tests for Anthropic 429 and 500 returning valid:false Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR introduces defensive error handling for API key validation, adds support for inline CLI arguments (--key=value syntax), makes sidecar debugging port optional, and enforces stricter test failures in the pre-push hook. Changes span multiple modules with corresponding test updates. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/cli.js (1)
1-369: File exceeds 300 line limit.The file is currently ~369 lines, exceeding the 300-line limit specified in coding guidelines for
{src,bin,scripts}/**/*.js. Consider extracting validation functions (validateStartArgs, validators) into a separate module likesrc/cli-validators.js.As per coding guidelines: "File size limit of 300 lines per file in src/, bin/, or scripts/ directories".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cli.js` around lines 1 - 369, This file exceeds the 300-line limit; extract the argument validation logic into a new module: create src/cli-validators.js and move validateStartArgs, isValidModelFormat, and isValidDurationFormat into it (preserve their behavior and any calls to validate* helpers like validatePromptContent, validateCwdPath, validateAgentMode, validateHeadlessAgent, validateMcpSpec, validateMcpConfigFile, validateApiKey, validateThinkingLevel and logger), export them, and update src/cli.js to require/import those functions and remove the moved definitions so parseArgs, parseValue, isBooleanFlag, getUsage, and DEFAULTS remain in cli.js; ensure module.exports still exposes parseArgs, getUsage, DEFAULTS and the validateStartArgs is re-exported from the new module.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/cli.js`:
- Around line 1-369: This file exceeds the 300-line limit; extract the argument
validation logic into a new module: create src/cli-validators.js and move
validateStartArgs, isValidModelFormat, and isValidDurationFormat into it
(preserve their behavior and any calls to validate* helpers like
validatePromptContent, validateCwdPath, validateAgentMode,
validateHeadlessAgent, validateMcpSpec, validateMcpConfigFile, validateApiKey,
validateThinkingLevel and logger), export them, and update src/cli.js to
require/import those functions and remove the moved definitions so parseArgs,
parseValue, isBooleanFlag, getUsage, and DEFAULTS remain in cli.js; ensure
module.exports still exposes parseArgs, getUsage, DEFAULTS and the
validateStartArgs is re-exported from the new module.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 82462b8f-8e0f-48b2-b389-6103c582fa8e
📒 Files selected for processing (8)
.husky/pre-pushelectron/ipc-setup.jssrc/cli.jssrc/sidecar/setup-window.jssrc/utils/api-key-validation.jstests/api-key-store-validation.test.jstests/cli.test.jstests/sidecar/setup-window.test.js
Summary
Cherry-picked and independently verified 6 bug fixes identified during review of #9. Each bug was reproduced before fixing.
{valid: true}SIDECAR_DEBUG_PORTget-api-keyshandler has no error handling,saveApiKeyfailures silently ignored--key=valuesyntax parsed as{"model=gemini": true}instead of{"model": "gemini"}npm audit || echofallback)What was NOT included
The auto-skills framework, activity monitoring hooks, and other feature work from #9 were not included. This PR is strictly bug fixes for existing code.
Test plan
--key=valueCLI syntax (4 tests)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
--key=value)Bug Fixes
Chores