Skip to content

spawn validate --nist-800-171 -o json silently prints a table: the compliance flags demand a value they then ignore #808

Closed

Description

@scttfrdmn

The two compliance flags are registered as StringVar, so pflag requires a
value — but the value is never read. The mode is decided by Changed(). The
result is that the flag eats the next argv token, and the documented JSON path
silently emits a human table.

The registration

cmd/validate.go:53-54:

validateCmd.Flags().StringVar(&validateComplianceMode, "nist-800-171", "", "Validate NIST 800-171 compliance")
validateCmd.Flags().StringVar(&validateComplianceMode, "nist-800-53", "", "Validate NIST 800-53 compliance (low, moderate, high)")

No NoOptDefVal, so a value is mandatory. And validateComplianceMode has
exactly two references in non-test code — those two lines. The actual decision is
at cmd/validate.go:70-72 via cmd.Flags().Changed(...), which ignores the
value entirely.

For --nist-800-53 a value is meaningful (low|moderate|high). For
--nist-800-171 there is nothing to supply, yet one is demanded.

Three consequences, all verified against the built binary

1. The command's own documented Example fails.

$ spawn validate --nist-800-171
flag needs an argument: --nist-800-171

That exact invocation appears as an Example at cmd/validate.go:37 and as the
command's own error-message remedy at :82:

compliance mode required: use --nist-800-171 or --nist-800-53=<low|moderate|high>

So the fix the tool prints does not work either.

2. -o json is swallowed and the output is a table — exit 0.

$ spawn validate --nist-800-171 -o json

pflag consumes -o as the flag's value, leaving json as a positional
argument. The command runs, scans, and prints the table report. A script
parsing that output gets human-formatted text with a success exit code — the
worst failure shape, because nothing signals it.

3. The --instance-id Example is doubly broken.

cmd/validate.go:40 documents
spawn validate --instance-id i-0abc123 --nist-800-171. It fails the same arity
way, and even once parsed, cmd/validate.go:109 returns
"single instance validation not yet implemented".

Suggested

Make the flags' arity match how they are consumed:

A gate worth having: for every flag registered as StringVar, either the
variable is read somewhere, or NoOptDefVal is set. A string flag whose value is
never read but is still mandatory will always swallow the following argument, and
that is invisible until someone combines it with another flag.

Activity

  1. added
    bug
    on Oct 11, 2026
  2. added a commit that references this issue on Oct 11, 2026
    a68a99e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions