{"record":{"id":"142aaf5af166423d","repo":"hashicorp/terraform","slug":"unknown-view-type-v-142aaf","errorCode":null,"errorMessage":"unknown view type %v","messagePattern":"unknown view type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/command/views/test.go","lineNumber":95,"sourceCode":"\t// status of their ongoing remote test run.\n\tTFCStatusUpdate(status tfe.TestRunStatus, elapsed time.Duration)\n\n\t// TFCRetryHook prints an update if a request failed and is being retried.\n\tTFCRetryHook(attemptNum int, resp *http.Response)\n}\n\nfunc NewTest(vt arguments.ViewType, view *View) Test {\n\tswitch vt {\n\tcase arguments.ViewJSON:\n\t\treturn &TestJSON{\n\t\t\tview: NewJSONView(view),\n\t\t}\n\tcase arguments.ViewHuman:\n\t\treturn &TestHuman{\n\t\t\tview: view,\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown view type %v\", vt))\n\t}\n}\n\ntype TestHuman struct {\n\tCloudHooks\n\n\tview *View\n}\n\nvar _ Test = (*TestHuman)(nil)\n\nfunc (t *TestHuman) Abstract(_ *moduletest.Suite) {\n\t// Do nothing, we don't print an abstract for the human view.\n}\n\nfunc (t *TestHuman) Conclusion(suite *moduletest.Suite) {\n\tt.view.streams.Println()\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/views/test.go#L77-L113","documentation":"NewTest (internal/command/views/test.go:84) switches over arguments.ViewType and returns TestJSON for ViewJSON or TestHuman for ViewHuman; any other value panics 'unknown view type %v'. 'terraform test' only supports human and JSON output.","triggerScenarios":"NewTest is called with ViewRaw ('R'), ViewNone (0), or any rune other than ViewHuman/ViewJSON. The test argument parser (internal/command/arguments/test.go) only ever sets ViewJSON or ViewHuman, so reaching the panic implies an uninitialized/leaked ViewType or a new view mode added without a Test implementation.","commonSituations":"A code path constructing arguments.Test{} without setting ViewType (leaving ViewNone), or a future ViewType constant introduced without a Test view variant.","solutions":["Ensure every constructor of arguments.Test sets ViewType explicitly (default to ViewHuman when -json is absent).","If introducing a new ViewType, add the corresponding Test implementation and its case here together.","Add a test covering NewTest for each defined ViewType constant.","As an end user, report the internal bug with the 'terraform test' invocation that crashed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func validTestViewType(vt arguments.ViewType) bool {\n    return vt == arguments.ViewHuman || vt == arguments.ViewJSON\n}\nif !validTestViewType(args.ViewType) {\n    return nil, fmt.Errorf(\"terraform test requires ViewHuman or ViewJSON, got %v\", args.ViewType)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default ViewType to ViewHuman in the test argument parser when -json is absent.","Cover NewTest for every defined ViewType constant in a unit test.","When adding a ViewType, add the matching Test implementation and its case together."],"tags":["panic","view-type","exhaustive-switch","test-command","internal-bug"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}