Skip to content

Reject empty slice flags in CLI commands that require them - #4263

Draft
roman-khimov with Copilot wants to merge 2 commits into
masterfrom
copilot/check-cobra-commands-flags
Draft

roman-khimov with Copilot wants to merge 2 commits into
masterfrom
copilot/check-cobra-commands-flags

Conversation

Copilot AI commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Cobra parses --flag "" into an empty slice. This is indistinguishable from the flag being omitted, but it passes the MarkFlagRequired check. Commands that loop over such a flag silently do nothing, or send a request with an empty list, instead of failing.

$ neofs-cli object lock --cid <cid> --oid '' --lifetime 100 -r localhost:8080
# before: continues and fails later with "container not found"
# after:  Error: provide at least one object via oid flag

Each of the commands below now fails fast with "provide at least one … via -- flag" when the parsed slice has no elements:

  • neofs-cli object lock: the --oid flag.
  • neofs-cli control drop-objects: the --objects flag.
  • neofs-adm fschain: container IDs flag, checked in getCIDs.
  • neofs-lancet fstree and meta remove: the --addresses flag.

object delete already had this check, so it is unchanged.

Not covered: other slice flags (shard IDs, attributes, search filters, session subjects, X-headers) are untouched. Their empty value is either a valid input or not clearly a bug. Say if you want them checked too.

Co-authored-by: roman-khimov <22092804+roman-khimov@users.noreply.github.com>
Copilot AI changed the title [WIP] Check Cobra commands for slice flag emptiness Reject empty slice flags in CLI commands that require them Oct 29, 2026
Copilot AI requested a review from roman-khimov October 29, 2026 20:55

This branch has not been deployed

No deployments
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.

Check that all Cobra commands check length slice flags for emptiness if required

2 participants