Skip to content

setup-plan.ps1 silently ignores unrecognized positional arguments (setup-tasks.ps1 rejects them) #3750

Description

@kurtvalcorza

Summary

scripts/powershell/setup-plan.ps1 captures extra positional arguments via ValueFromRemainingArguments but never validates them, so a misspelled or unsupported option is silently ignored and the script reports success. Its sibling setup-tasks.ps1 rejects the same input.

The inconsistency

scripts/powershell/setup-plan.ps1 captures but never checks:

    # Capture extra positional arguments to match Bash/Python behavior.
    [Parameter(ValueFromRemainingArguments = $true)]
    [string[]]$RemainingArgs
)

scripts/powershell/setup-tasks.ps1:20-23 does check:

if ($RemainingArgs.Count -gt 0) {
    [Console]::Error.WriteLine("ERROR: Unknown option '$($RemainingArgs[0])'")
    exit 1
}

Impact

In automation, ./setup-plan.ps1 -Jsonn (or any unsupported positional) proceeds as though no option were passed, creates or reports a plan, and exits 0. The invocation error is masked rather than surfaced — the failure mode setup-tasks.ps1 was explicitly changed to prevent.

Suggested fix

Mirror setup-tasks.ps1: validate after help handling and before any filesystem work, so -Help still wins and exits 0 consistently with the Bash/Python variants.

if ($Help) { ...; exit 0 }

if ($RemainingArgs.Count -gt 0) {
    [Console]::Error.WriteLine("ERROR: Unknown option '$($RemainingArgs[0])'")
    exit 1
}

Worth checking the other scripts/powershell/*.ps1 entry points for the same gap — this looks like validation added to setup-tasks.ps1 that wasn't propagated to its siblings.

Version

Reproduced on main @ c0fe0e4 (v0.14.2).

Found by an automated review pass over a vendored copy in a downstream project; verified against upstream main before filing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions