Skip to content

Commands without their own options silently ignore unknown options #314

Description

@rdeago

Affected version(s)

2.1.12-preview (and current main)

Is this a regression?

NO - This bug also affected the previous version

Context

Option validation for bv subcommands lives in two places: CommandArgumentValidator (rejects forwarded tokens and excess positionals) and each command's *Settings.Parse, which throws on reader.Remaining.Count > 0. Commands with no settings type (clean, version show) have no Parse — so their option tokens are never inspected by anyone.

Expected behavior

> bv clean --bogus
error: Unknown option '--bogus' for command 'clean'.

Actual behavior

--bogus is silently ignored and the command runs normally. Typos in real options or options meant for another subcommand go unnoticed.

How to reproduce

dotnet bv clean --bogus — exits 0, cleans as if nothing happened.

Configuration

bv CLI tool, any OS.

Other information

Likely fix: in CommandArgumentValidator, reject any leftover option token for non-forwarding commands whose SettingsType is null (commands with settings keep their existing Remaining check).

Acceptance criteria:

  • unknown options are rejected for settings-less commands;
  • tests cover both settings-less and settings-carrying commands;
  • CHANGELOG entry under Unreleased changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug[issue/PR] reports / solves a bug.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions