hashicorp/terraform · critical
unrecognized status: %s
Error message
unrecognized status: %s
What it means
colorizeTestStatus (internal/command/views/test.go:788) switches over moduletest.Status and panics 'unrecognized status' for values other than Error/Fail/Pass/Skip/Pending. moduletest.Status is an iota enum (status.go:19-25) with exactly those five members; the function renders the ANSI-colored label for the human view.
Source
Thrown at internal/command/views/test.go:790
func (t *TestJSON) TFCRetryHook(attemptNum int, resp *http.Response) {
t.view.log.Error(
t.RetryLogHook(attemptNum, resp, false),
"type", json.MessageTestRetry,
)
}
func colorizeTestStatus(status moduletest.Status, color *colorstring.Colorize) string {
switch status {
case moduletest.Error, moduletest.Fail:
return color.Color("[red]fail[reset]")
case moduletest.Pass:
return color.Color("[green]pass[reset]")
case moduletest.Skip:
return color.Color("[light_gray]skip[reset]")
case moduletest.Pending:
return color.Color("[light_gray]pending[reset]")
default:
panic("unrecognized status: " + status.String())
}
}
func testStatus(status moduletest.Status) string {
switch status {
case moduletest.Error, moduletest.Fail:
return "fail"
case moduletest.Pass:
return "pass"
case moduletest.Skip:
return "skip"
case moduletest.Pending:
return "pending"
default:
panic("unrecognized status: " + status.String())
}
}
View on GitHub (pinned to d32a084675)
Solutions
- When adding a moduletest.Status constant, update colorizeTestStatus and testStatus (and json.ToTestStatus) in the same change.
- Add an exhaustive test over all Status constants through both rendering helpers.
- Validate Status is within range before it reaches the view layer.
- As an end user, report the internal bug with the 'terraform test' output.
Defensive patterns
Strategy: validation
Validate before calling
func validStatus(s moduletest.Status) bool {
switch s {
case moduletest.Pending, moduletest.Skip, moduletest.Pass, moduletest.Fail, moduletest.Error:
return true
}
return false
}
if !validStatus(status) {
return "" // or return an error to the caller
} Prevention
- When adding a moduletest.Status constant, update colorizeTestStatus, testStatus, and json.ToTestStatus together.
- Exhaustively test every Status constant through both renderers.
- Validate Status range before the view layer if Status can originate from untrusted data.
When it happens
Trigger: colorizeTestStatus receives a moduletest.Status outside the five defined constants — only possible if a new Status member is added without updating this switch, or a zero/uninitialised Status reaches rendering (note: Pending is handled, so zero-value is safe).
Common situations: Adding a new test status (e.g. 'Warning') and forgetting the colorize branch; a regression producing an out-of-range Status integer.
Related errors
- unrecognized test progress: %s
- (*StateMigrateHuman)LogStateMigrationErrored: called incorre
- unknown view type %v
- unknown view type %v
- missing message for InstallingProviderMessage init message c
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/812048e1f16cde89.
Report an issue: GitHub.