Skip to content

fix(cli): rename subcommand --config to --json-config (was shadowed)#34

Merged
joalves merged 2 commits into
mainfrom
fix/json-config-option-rename
May 11, 2026
Merged

fix(cli): rename subcommand --config to --json-config (was shadowed)#34
joalves merged 2 commits into
mainfrom
fix/json-config-option-rename

Conversation

@joalves
Copy link
Copy Markdown
Collaborator

@joalves joalves commented May 11, 2026

Summary

The program-level --config <path> option shadowed the same-named subcommand --config <json>, so commander never bound the JSON body. Every create / update / test / introspect / validate-query / preview-query invocation that took --config <json> failed with error: 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:

  • `datasources` — create, update, test, introspect, validate-query, preview-query
  • `storage-configs` — create, update, test
  • `export-configs` — create, update
  • `update-schedules` — create, update
  • `action-dialog-fields` — create, update
  • `statistics power-matrix` — `--config` option (now `--json-config`)

Global `--config ` (config file) is unchanged.

README CLI examples and inline error messages updated to match.

Test plan

  • `bun run test` — full suite passes (no regressions in 57 affected tests)
  • `bun run lint` — clean
  • `bun run build` — clean
  • Empirical: `bun src/index.ts datasources create --profile local --json-config '{...}'` now reaches the backend (which then validates the body normally, instead of commander silently dropping the option)
  • Manual smoke: `abs storage-configs create --json-config '{...}'`, `abs export-configs create --json-config '{...}'`, `abs statistics power-matrix --json-config '{...}'`

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

    • Updated README command examples to use the --json-config option for JSON configuration inputs.
  • Updates

    • Standardised JSON configuration handling across CLI commands by replacing the --config flag with --json-config for action-dialog-fields, datasources, export-configs, storage-configs, update-schedules, and power-matrix commands.

Review Change Stack

joalves added 2 commits May 11, 2026 18:31
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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Walkthrough

This pull request systematically renames the CLI configuration input flag from --config to --json-config across seven command modules. The change affects statistics (power-matrix), storage-configs (create/update/test), datasources (six subcommands), action-dialog-fields, export-configs, and update-schedules commands. Each command implementation now requires the new --json-config option, parses options.jsonConfig via validateJSON, and routes the parsed config to existing core API calls. All corresponding test files and README examples are updated to reflect the new flag name. No changes to underlying business logic, API contracts, or return values occur.

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 --config to --json-config in CLI option declarations, update property access from options.config to options.jsonConfig, and adjust validation/error message references. Tests follow the same systematic update. The changes require mechanical verification rather than complex logic evaluation.

Poem

🐰 Hops with glee, a flag so fine,
From --config to --json-config in line,
Seven commands dance in sync,
Tests and docs, all in a blink,
A refactor neat—the rabbit's design!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: renaming the --config option to --json-config to resolve a shadowing issue with the global --config flag.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/json-config-option-rename

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7867bfa and df9c8cb.

📒 Files selected for processing (13)
  • README.md
  • src/commands/actiondialogfields/actiondialogfields.test.ts
  • src/commands/actiondialogfields/index.ts
  • src/commands/datasources/datasources.test.ts
  • src/commands/datasources/index.ts
  • src/commands/exportconfigs/exportconfigs.test.ts
  • src/commands/exportconfigs/index.ts
  • src/commands/statistics/index.ts
  • src/commands/statistics/statistics.test.ts
  • src/commands/storageconfigs/index.ts
  • src/commands/storageconfigs/storageconfigs.test.ts
  • src/commands/updateschedules/index.ts
  • src/commands/updateschedules/updateschedules.test.ts

Comment on lines +57 to 60
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)');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

@joalves joalves merged commit a3b8c7a into main May 11, 2026
5 checks passed
@joalves joalves deleted the fix/json-config-option-rename branch May 12, 2026 09:03
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