#2825·reviewdog

FailLevel.ShouldFail() treats UNKNOWN_SEVERITY as more severe than ERROR, causing spurious failures

Author: shogo82148Created Sep 22, 2026Updated Sep 22, 2026

What happens

FailLevel.ShouldFail() in fail_level.go fails the run for any issue with rdf.Severity_UNKNOWN_SEVERITY, regardless of the configured -fail-level, except when -fail-level=none/default. This is not the intended "fail on any severity" behavior of -fail-level=any — it also fires for -fail-level=error, warning, and info.

Originally reported/diagnosed at https://github.com/reviewdog/action-shellcheck/issues/100, where shellcheck's diff-format suggestion pass (which carries no severity info at all) always fails the job once -fail-level is anything other than none.

Root cause

go
// fail_level.go
func (failLevel FailLevel) ShouldFail(severity rdf.Severity) bool {
	if failLevel == FailLevelDefault || failLevel == FailLevelNone {
		return false
	}
	minSeverity := failLevel.minSeverity()
	return minSeverity == rdf.Severity_UNKNOWN_SEVERITY || severity <= minSeverity
}
protobuf
// proto/rdf/reviewdog.proto
enum Severity {
  UNKNOWN_SEVERITY = 0;
  ERROR = 1;
  WARNING = 2;
  INFO = 3;
}

UNKNOWN_SEVERITY is the Go zero-value (0), which numerically sorts below ERROR (1). So for -fail-level=error, minSeverity = ERROR(1), and the second clause severity <= minSeverity evaluates UNKNOWN_SEVERITY(0) <= ERROR(1) → true. An issue whose severity is simply unknown (e.g. because the source format doesn't carry severity, like reviewdog's diff format) is misinterpreted as "more severe than error" and always trips the fail threshold. The same holds for -fail-level=warning and -fail-level=info.

The first clause (minSeverity == UNKNOWN_SEVERITY) is presumably meant to implement -fail-level=any (fail regardless of severity), but as written it's indistinguishable from the unrelated "issue has unknown severity" case handled (incorrectly) by the second clause.

Reproduction

bash
$ printf '#!/usr/bin/env bash\necho $1\n' > test.sh
$ shellcheck -f diff test.sh | reviewdog \
    -name="shellcheck (suggestion)" -f=diff -f.diff.strip=1 \
    -reporter=local -fail-level=error
test.sh:2:-echo $1
test.sh:2:+echo "$1"
reviewdog: found at least one issue with severity greater than or equal to the given level: error
$ echo $?
1

reviewdog version: v0.21.2 (but the logic is unchanged as of current master, AFAICT from reading the source on GitHub).

Suggested fix

Special-case UNKNOWN_SEVERITY issues so they don't automatically satisfy a numeric threshold, while keeping -fail-level=any's "fail regardless of severity" semantics explicit:

go
func (failLevel FailLevel) ShouldFail(severity rdf.Severity) bool {
	if failLevel == FailLevelDefault || failLevel == FailLevelNone {
		return false
	}
	if failLevel == FailLevelAny {
		return true
	}
	if severity == rdf.Severity_UNKNOWN_SEVERITY {
		return false
	}
	return severity <= failLevel.minSeverity()
}

Happy to send a PR with this change plus a test if that's the right direction — let me know.