Skip to content

Fixes command execution failing with Positional parameter not supported: [object Object] - #161

Merged
githubsaturn merged 1 commit into
caprover:masterfrom
aibus-dev:fix/commander-action-params
Aug 6, 2026
Merged

Fixes command execution failing with Positional parameter not supported: [object Object]#161
githubsaturn merged 1 commit into
caprover:masterfrom
aibus-dev:fix/commander-action-params

Conversation

@tungnt2k

@tungnt2k tungnt2k commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary
Fixes command execution failing with Positional parameter not supported: [object Object] by correctly handling the Commander v12 action callback parameters.

Problem
Commander v12 passes the parsed options object and the Command instance to action handlers after any declared positional arguments.

The existing implementation checks the raw callback argument count and mistakenly treats these standard parameters as a positional argument. As a result, normal commands fail before execution and display the parsed options object as [object Object].
Screenshot 2026-08-06 at 11 54 33 AM

Changes
Extracted the Commander Command instance from the action callback arguments.
Read parsed command-line options using command.opts().
Preserved the existing validation for actual positional arguments.
This is a four-line, targeted bug fix with no refactoring or unrelated changes.

Verification
npm run formatter
npm run build
Verified that regular command options are parsed successfully.
Verified that actual positional arguments are still rejected.

Checklist

  • I have read the contribution guidelines.
  • I have communicated the proposed change on the CapRover Slack channel.

Related issue: N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved command action handling by providing action hooks with parsed command options.
    • Preserved existing validation for positional parameters.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The command action handler now passes parsed Commander options to preAction. Existing positional-parameter validation remains unchanged.

Changes

Command action handling

Layer / File(s) Summary
Forward parsed command options
src/commands/Command.ts
The action callback removes the Commander command object from the action arguments and passes commanderCommand.opts() to preAction. Positional-parameter validation remains unchanged.

Estimated code review effort: 2 (Simple) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly describes the primary bug fix involving command execution and the positional-parameter error.
Description check ✅ Passed The description explains the problem, implementation, verification, and contribution checklist, and it aligns with the repository template.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@githubsaturn
githubsaturn merged commit 5da3b7d into caprover:master Aug 6, 2026
3 checks passed
@githubsaturn

Copy link
Copy Markdown
Collaborator

Thanks!

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.

2 participants