Skip to content

An unknown --fail-on value is an error instead of quietly meaning error - #25

Merged
avison9 merged 1 commit into
mainfrom
fix/fail-on-validation
Nov 14, 2026
Merged

avison9 merged 1 commit into
mainfrom
fix/fail-on-validation

Conversation

@avison9

@avison9 avison9 commented Nov 14, 2026

Copy link
Copy Markdown
Owner

What changes

  • --fail-on accepts exactly error, warning or info.
    • Anything else exits 2 before any file is read, with cdclint: --fail-on: unknown severity "warnings"; the severities are error, warning, info.
    • Before this change, a typo fell through to error, so --fail-on warnings let warnings pass silently.
  • action.yml: an empty fail-on input still means error, as it did before (${FAIL_ON:-error}). A workflow that passes an unset variable keeps working, and only a value that names no severity fails the step.
  • README: one clause saying any other value is an error.

Test first

  • TestAnUnknownFailOnIsAnErrorNotTheDefault failed on main for warnings, WARNING, err and "": exit 1 with findings printed. Now each is exit 2 with nothing on stdout.
  • The same test pins the three valid values and the threshold behaviour on include-list-typo (one error and one warning).

Verified

  • gofmt -l . is clean; go vet, go build and go test ./... pass (Docker, golang:1.25-bookworm).
  • RefuseRadar at origin/main with --base HEAD:
    • --fail-on warning and --fail-on error: 0 error(s), 0 warning(s), 162 info. These are the two values tools/cdclint.sh passes.
    • --fail-on warnings: rejected with the message above.
  • The Action's empty input expands to error under set -u.

Rejected

Accepting other spellings (warnings, WARNING). A gate's threshold is worth spelling exactly, and the error message says what to write.

Not in this PR

--format has the same fall-through: an unknown value prints text. That is visible rather than silent, so it is left for its own change if you want it.

`--fail-on warnings` (or WARNING, or err) used to fall through to the
default, error: a pipeline that asked to block on warnings let them pass
and believed it was guarded. cdclint now exits 2 before reading anything,
names the value and lists error, warning, info, as --disable already does
for an unknown rule.

The GitHub Action passed its input through unchanged, and an empty input
(a workflow templating an unset variable) used to mean error. It still
does: action.yml substitutes error for an empty input, so only a value
that names no severity fails the step.

Rejected: accepting other spellings (warnings, WARNING). A gate's
threshold is worth spelling exactly; an alias table is one more thing to
document, and the error message says what to write.
@avison9 avison9 self-assigned this Nov 14, 2026
@avison9
avison9 merged commit 9b35a60 into main Nov 14, 2026
2 checks passed
@avison9
avison9 deleted the fix/fail-on-validation branch November 14, 2026 10:58
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.

1 participant