Skip to content

pybind: Fix CLI error message when using force parameter if it doesn't exist - #70246

Merged
Hezko merged 1 commit into
ceph:mainfrom
Hezko:fix-force-param-err
Jul 19, 2026
Merged

Hezko merged 1 commit into
ceph:mainfrom
Hezko:fix-force-param-err

Conversation

@Hezko

@Hezko Hezko commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Running a command that has no force parameter with --force produces a cryptic error instead of a clean rejection:

[xxx@xxx ~]# ceph nvmeof ns del_host --nqn nqn.2016-06.io.spdk:cnode1.mygroup1 --force true
Error EINVAL: invalid literal for int() with base 10: '--force'

ceph_argparse.py hardcodes --force as an exception in the positional-argument validation loop (line 1244), originally added for backward compatibility with pre-Nautilus daemons that defined force as a CephString positional parameter instead of CephBool. The exception fired unconditionally — even when force was not part of the command's schema at all — allowing --force to be silently absorbed as the value of the next positional parameter (e.g. nsid). The module then tried int('--force') and crashed.

This PR fixes it:

[xxx@xxx ~]# ceph nvmeof ns del_host --nqn nqn.2016-06.io.spdk:cnode1.mygroup1 --force true
Invalid command: Unexpected argument '--force'
nvmeof ns del_host <nqn> <nsid> [<host_nqn>] [<gw_group>] [<server_address>] [<traddr>] :  Removes a host from the specified NVMeoF namespace
Error EINVAL: invalid command

Fixes: https://tracker.ceph.com/issues/78291

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@Hezko Hezko self-assigned this Jul 16, 2026
@Hezko
Hezko requested a review from vshankar July 16, 2026 07:32
@Hezko
Hezko force-pushed the fix-force-param-err branch from 1189ea8 to e8be5e2 Compare July 16, 2026 07:38
@vshankar
vshankar requested a review from tchaikov July 16, 2026 11:16

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm.

or myarg == "--yes-i-really-really-mean-it" \
or myarg == "--yes-i-really-really-mean-it-not-faking" \
or myarg == "--force" \
or (myarg == "--force" and 'force' in arg_descs_by_name) \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we could have dropped this special case. but unfortunately, the nvmeof mgr module declares force: Optional[str] = "false" under @NvmeofCLICommand, so we still need to keep it if we want to be backward compatible.

one gap though, there are three --yes-i-really-* flags above this line might need the same treatment. but the fix addresses the referenced issue. we could address the nvme (this could be risky) and --yes-i-really-* in follow-up changes.

@Hezko
Hezko merged commit 314d194 into ceph:main Jul 19, 2026
6 checks passed
@Hezko
Hezko deleted the fix-force-param-err branch July 19, 2026 22:15
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/29705813307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants