{"record":{"id":"acefef3f138afce0","repo":"hashicorp/terraform","slug":"unknown-view-type-v-acefef","errorCode":null,"errorMessage":"unknown view type %v","messagePattern":"unknown view type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/command/views/show.go","lineNumber":43,"sourceCode":"type Show interface {\n\t// Display renders the plan, if it is available. If plan is nil, it renders the statefile.\n\tDisplay(config *configs.Config, plan *plans.Plan, planJSON *cloudplan.RemotePlanJSON, stateFile *statefile.File, schemas *terraform.Schemas) int\n\n\t// Diagnostics renders early diagnostics, resulting from argument parsing.\n\tDiagnostics(diags tfdiags.Diagnostics)\n\n\t// DisplayResourceInstanceState displays the state for a single resource instance. Diagnostics from the state show command are included in the json output.\n\tDisplayResourceInstanceState(jsonformat.State, tfdiags.Diagnostics) int\n}\n\nfunc NewShow(vt arguments.ViewType, view *View) Show {\n\tswitch vt {\n\tcase arguments.ViewJSON:\n\t\treturn &ShowJSON{view: view}\n\tcase arguments.ViewHuman:\n\t\treturn &ShowHuman{view: view}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown view type %v\", vt))\n\t}\n}\n\ntype ShowHuman struct {\n\tview *View\n}\n\nvar _ Show = (*ShowHuman)(nil)\n\nfunc (v *ShowHuman) DisplayResourceInstanceState(state jsonformat.State, diags tfdiags.Diagnostics) int {\n\trenderer := jsonformat.Renderer{\n\t\tStreams:             v.view.streams,\n\t\tColorize:            v.view.colorize,\n\t\tRunningInAutomation: v.view.runningInAutomation,\n\t}\n\n\tif diags.HasErrors() {\n\t\tv.Diagnostics(diags)","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/views/show.go#L25-L61","documentation":"This panic fires in NewShow when arguments.ViewType is neither ViewJSON nor ViewHuman. ViewType is `type ViewType rune`; the show switch has no case for ViewNone(0) or ViewRaw('R').","triggerScenarios":"`terraform show` invoked with a ViewType the show constructor does not recognize: zero-value ViewType from code that skipped flag parsing, ViewRaw passed to show (not supported here), or a newly added enum value without a matching case.","commonSituations":"A test constructs ShowArgs with the default zero ViewType. A maintainer adds a ViewType and forgets to extend NewShow. End users cannot trigger it via flags.","solutions":["In any code/test calling NewShow, set ViewType explicitly to arguments.ViewHuman or arguments.ViewJSON.","When adding a ViewType to arguments/types.go, add a case to views/show.go:43 and every sibling New* switch.","Cover the new case with show_test.go."],"exampleFix":"// before\ns := arguments.Show{} // ViewType == ViewNone\nv := views.NewShow(s.ViewType, view)\n// after\ns := arguments.Show{ViewType: arguments.ViewHuman}\nv := views.NewShow(s.ViewType, view)","handlingStrategy":"type-guard","validationCode":"switch vt {\ncase arguments.ViewHuman, arguments.ViewJSON:\n  // ok\ndefault:\n  return fmt.Errorf(\"unsupported show view type: %v\", vt)\n}","typeGuard":"func isValidShowViewType(vt arguments.ViewType) bool {\n  return vt == arguments.ViewHuman || vt == arguments.ViewJSON\n}","tryCatchPattern":null,"preventionTips":["Set ViewType explicitly in arguments.Show test fixtures.","Add a case for any new ViewType to NewShow (and sibling constructors).","Run show_test.go after touching arguments/types.go."],"tags":["terraform-cli","views","show","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"}