{"record":{"id":"407738085b0febda","repo":"hashicorp/terraform","slug":"unknown-view-type-v-407738","errorCode":null,"errorMessage":"unknown view type %v","messagePattern":"unknown view type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/command/views/refresh.go","lineNumber":41,"sourceCode":"\tDiagnostics(diags tfdiags.Diagnostics)\n\tHelpPrompt()\n}\n\n// NewRefresh returns an initialized Refresh implementation for the given ViewType.\nfunc NewRefresh(vt arguments.ViewType, view *View) Refresh {\n\tswitch vt {\n\tcase arguments.ViewJSON:\n\t\treturn &RefreshJSON{\n\t\t\tview: NewJSONView(view),\n\t\t}\n\tcase arguments.ViewHuman:\n\t\treturn &RefreshHuman{\n\t\t\tview:         view,\n\t\t\tinAutomation: view.RunningInAutomation(),\n\t\t\tcountHook:    &countHook{},\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown view type %v\", vt))\n\t}\n}\n\n// The RefreshHuman implementation renders human-readable text logs, suitable for\n// a scrolling terminal.\ntype RefreshHuman struct {\n\tview *View\n\n\tinAutomation bool\n\n\tcountHook *countHook\n}\n\nvar _ Refresh = (*RefreshHuman)(nil)\n\nfunc (v *RefreshHuman) Outputs(outputValues map[string]*states.OutputValue) {\n\tif len(outputValues) > 0 {\n\t\tv.view.streams.Print(v.view.colorize.Color(\"[reset][bold][green]\\nOutputs:\\n\\n\"))","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/views/refresh.go#L23-L59","documentation":"This panic fires in NewRefresh when arguments.ViewType is neither ViewJSON nor ViewHuman. The refresh switch has no case for ViewNone(0) or ViewRaw('R').","triggerScenarios":"`terraform refresh` (now apply -refresh-only) invoked with a ViewType the refresh constructor does not recognize: zero-value ViewType from test code skipping flag parsing, ViewRaw, or a future enum value.","commonSituations":"A test builds a Refresh view with the default zero ViewType. A maintainer adds a ViewType and forgets to extend NewRefresh. End users cannot trigger via flags.","solutions":["Set ViewType explicitly to arguments.ViewHuman or arguments.ViewJSON in any code/test calling NewRefresh.","Add a case for any new ViewType to views/refresh.go:41 (and sibling New* switches).","Cover with refresh_test.go."],"exampleFix":"// before\nr := arguments.Refresh{} // ViewType == ViewNone\nv := views.NewRefresh(r.ViewType, view)\n// after\nr := arguments.Refresh{ViewType: arguments.ViewHuman}\nv := views.NewRefresh(r.ViewType, view)","handlingStrategy":"type-guard","validationCode":"switch vt {\ncase arguments.ViewHuman, arguments.ViewJSON:\n  // ok\ndefault:\n  return fmt.Errorf(\"unsupported refresh view type: %v\", vt)\n}","typeGuard":"func isValidRefreshViewType(vt arguments.ViewType) bool {\n  return vt == arguments.ViewHuman || vt == arguments.ViewJSON\n}","tryCatchPattern":null,"preventionTips":["Set ViewType explicitly in arguments.Refresh test fixtures.","Keep NewRefresh in sync with ViewType enum changes.","Run refresh_test.go after editing the enum."],"tags":["terraform-cli","views","refresh","panic","invariant","view-type"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}