Skip to content

fix(cli): validate option values instead of dropping bad ones#874

Merged
Chemaclass merged 1 commit into
mainfrom
fix/validate-flag-values
Jul 25, 2026
Merged

fix(cli): validate option values instead of dropping bad ones#874
Chemaclass merged 1 commit into
mainfrom
fix/validate-flag-values

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #873

The numeric settings are compared with [ -lt ], which errors instead of returning
false on a non-integer operand, and nothing validated them. --jobs abc hung on
the Bash macOS ships (the job-slot poll never reached its break) and was silently
ignored on Bash 4.3+. --coverage-min abc leaked a raw shell error and still exited
0, so a CI job reported success without enforcing its threshold.

💡 Changes

  • Reject a non-integer or negative value for --jobs, --retry, --test-timeout and --coverage-min, and an unsupported --output format, with a message naming the setting and a non-zero exit
  • Validate once on the resolved configuration after flag parsing, so the BASHUNIT_* environment variables that bypass the parser are covered by the same gate
  • Add acceptance coverage for each bad value, the env-var path, and regression guards that --jobs auto, --output tap and valid numbers still work

The numeric settings are compared with [ -lt ], which errors instead of
returning false on a non-integer operand. Nothing validated them, so:

  --jobs abc          hung on Bash 3.x (the job-slot poll never reached
                      its break) and was ignored on Bash 4.3+
  --coverage-min abc  leaked '[: abc: integer expression expected' and
                      still exited 0, so the threshold went unenforced
  --retry/-timeout    silently dropped
  --output nonsense   silently fell back to the default renderer

Validation runs once on the resolved configuration, after flag parsing,
so it covers the BASHUNIT_* environment variables that bypass the parser
as well as the flags.

Closes #873
@Chemaclass Chemaclass added the bug Something isn't working label Jul 25, 2026
@Chemaclass Chemaclass self-assigned this Jul 25, 2026
@Chemaclass
Chemaclass merged commit dc32473 into main Jul 25, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/validate-flag-values branch July 25, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant