fix(cli): rename subcommand --config to --json-config (was shadowed)#34
Conversation
The program-level --config <path> option shadowed the same-named subcommand option, so commander never bound the JSON body — every `create`/`update`/`test`/`introspect`/`validate-query`/`preview-query` invocation that took --config <json> failed with "required option --config not specified". The unit tests passed because they call `subcommand.parseAsync(...)` directly and bypass the program-level parser. CI never invoked the binary against a real backend, so the bug went unnoticed since the datasource/storage-config/export-config feature shipped. Renaming the per-subcommand option to --json-config across all affected groups (datasources, storage-configs, export-configs, update-schedules, action-dialog-fields, statistics) keeps the global --config <path> as the config-file flag while letting JSON bodies through unambiguously.
WalkthroughThis pull request systematically renames the CLI configuration input flag from Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes This is a straightforward, homogeneous flag rename applied consistently across multiple command files. The pattern is identical across all changes: swap Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/commands/actiondialogfields/index.ts`:
- Around line 57-60: The validation error messages still refer to the old flag
name '--config' despite calling validateJSON(options.jsonConfig,
'--json-config'); update the thrown Error string(s) to reference '--json-config'
instead of '--config' (specifically in the block checking config after
validateJSON and the similar check around lines 77-80), ensuring any user-facing
text passed from validateJSON/options.jsonConfig mentions '--json-config'
consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cab54181-c47d-44a8-8cd4-285ad277e5e1
📒 Files selected for processing (13)
README.mdsrc/commands/actiondialogfields/actiondialogfields.test.tssrc/commands/actiondialogfields/index.tssrc/commands/datasources/datasources.test.tssrc/commands/datasources/index.tssrc/commands/exportconfigs/exportconfigs.test.tssrc/commands/exportconfigs/index.tssrc/commands/statistics/index.tssrc/commands/statistics/statistics.test.tssrc/commands/storageconfigs/index.tssrc/commands/storageconfigs/storageconfigs.test.tssrc/commands/updateschedules/index.tssrc/commands/updateschedules/updateschedules.test.ts
| const config = validateJSON(options.jsonConfig, '--json-config'); | ||
| if (config === null || Array.isArray(config) || typeof config !== 'object') { | ||
| throw new Error('--config must be a JSON object (not null, array, or primitive)'); | ||
| } |
There was a problem hiding this comment.
Fix stale option name in validation errors.
Line [59] and Line [79] still reference --config, but the command now uses --json-config. This gives incorrect guidance on failure.
Suggested patch
- throw new Error('--config must be a JSON object (not null, array, or primitive)');
+ throw new Error('--json-config must be a JSON object (not null, array, or primitive)');
...
- throw new Error('--config must be a JSON object (not null, array, or primitive)');
+ throw new Error('--json-config must be a JSON object (not null, array, or primitive)');Also applies to: 77-80
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/commands/actiondialogfields/index.ts` around lines 57 - 60, The
validation error messages still refer to the old flag name '--config' despite
calling validateJSON(options.jsonConfig, '--json-config'); update the thrown
Error string(s) to reference '--json-config' instead of '--config' (specifically
in the block checking config after validateJSON and the similar check around
lines 77-80), ensuring any user-facing text passed from
validateJSON/options.jsonConfig mentions '--json-config' consistently.
Summary
The program-level
--config <path>option shadowed the same-named subcommand--config <json>, so commander never bound the JSON body. Everycreate/update/test/introspect/validate-query/preview-queryinvocation that took--config <json>failed witherror: required option --config <json> not specified.Confirmed empirically by invoking `bun src/index.ts datasources create --profile local --config '{...}'` — commander returned the error above. After renaming to `--json-config`, the same invocation reaches the backend and the backend responds normally.
The unit tests passed because they call `subcommand.parseAsync(...)` directly and bypass the program-level parser. CI never invokes the binary against a real backend, so the bug went unnoticed since the datasource/storage-config/export-config commands shipped.
What changed
Per-subcommand option `--config ` renamed to `--json-config` across:
Global `--config ` (config file) is unchanged.
README CLI examples and inline error messages updated to match.
Test plan
Breaking change?
Technically yes — anyone scripted against `--config ` will need to update. In practice the old option was 100% broken (it never reached the action handler), so nothing real should break.
Summary by CodeRabbit
Release Notes
Documentation
--json-configoption for JSON configuration inputs.Updates
--configflag with--json-configfor action-dialog-fields, datasources, export-configs, storage-configs, update-schedules, and power-matrix commands.