{"record":{"id":"812048e1f16cde89","repo":"hashicorp/terraform","slug":"unrecognized-status-s","errorCode":null,"errorMessage":"unrecognized status: %s","messagePattern":"unrecognized status: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/command/views/test.go","lineNumber":790,"sourceCode":"func (t *TestJSON) TFCRetryHook(attemptNum int, resp *http.Response) {\n\tt.view.log.Error(\n\t\tt.RetryLogHook(attemptNum, resp, false),\n\t\t\"type\", json.MessageTestRetry,\n\t)\n}\n\nfunc colorizeTestStatus(status moduletest.Status, color *colorstring.Colorize) string {\n\tswitch status {\n\tcase moduletest.Error, moduletest.Fail:\n\t\treturn color.Color(\"[red]fail[reset]\")\n\tcase moduletest.Pass:\n\t\treturn color.Color(\"[green]pass[reset]\")\n\tcase moduletest.Skip:\n\t\treturn color.Color(\"[light_gray]skip[reset]\")\n\tcase moduletest.Pending:\n\t\treturn color.Color(\"[light_gray]pending[reset]\")\n\tdefault:\n\t\tpanic(\"unrecognized status: \" + status.String())\n\t}\n}\n\nfunc testStatus(status moduletest.Status) string {\n\tswitch status {\n\tcase moduletest.Error, moduletest.Fail:\n\t\treturn \"fail\"\n\tcase moduletest.Pass:\n\t\treturn \"pass\"\n\tcase moduletest.Skip:\n\t\treturn \"skip\"\n\tcase moduletest.Pending:\n\t\treturn \"pending\"\n\tdefault:\n\t\tpanic(\"unrecognized status: \" + status.String())\n\t}\n}\n","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/views/test.go#L772-L808","documentation":"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.","triggerScenarios":"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).","commonSituations":"Adding a new test status (e.g. 'Warning') and forgetting the colorize branch; a regression producing an out-of-range Status integer.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func validStatus(s moduletest.Status) bool {\n    switch s {\n    case moduletest.Pending, moduletest.Skip, moduletest.Pass, moduletest.Fail, moduletest.Error:\n        return true\n    }\n    return false\n}\nif !validStatus(status) {\n    return \"\" // or return an error to the caller\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["panic","exhaustive-switch","test-command","status","enum","internal-bug","rendering"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}