{"record":{"id":"012d32c6441851db","repo":"hashicorp/terraform","slug":"missing-message-for-installingprovidermessage-init","errorCode":null,"errorMessage":"missing message for InstallingProviderMessage init message code","messagePattern":"missing message for InstallingProviderMessage init message code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/command/views/state_migrate.go","lineNumber":172,"sourceCode":"func (s *StateMigrateHuman) Log(message string, params ...any) {\n\ts.log(fmt.Sprintf(message, params...))\n}\n\nfunc (s *StateMigrateHuman) log(preparedMessage string) {\n\tmsg := s.view.colorize.Color(strings.TrimSpace(preparedMessage))\n\ts.view.streams.Println(msg)\n}\n\n// Implements Spacer\nfunc (s *StateMigrateHuman) Spacer() {\n\ts.view.Spacer()\n}\n\n// Implements ProviderInstallationLogger interface.\nfunc (s *StateMigrateHuman) Output(code InitMessageCode, params ...any) {\n\tmsg, ok := MessageRegistry[code]\n\tif !ok {\n\t\tpanic(\"missing message for InstallingProviderMessage init message code\")\n\t}\n\ts.Log(msg.HumanValue, params...)\n}\n\n// Implements ProviderInstallationLogger interface.\nfunc (s *StateMigrateHuman) LogInstallStateStoreProviderStart(pAddr tfaddr.Provider, cons getproviders.VersionConstraints, storeType string) {\n\tconsSuffix := \"\"\n\tif len(cons) > 0 {\n\t\tconsSuffix = fmt.Sprintf(\" (%s)\", getproviders.VersionConstraintsString(cons))\n\t}\n\tparams := []any{pAddr.ForDisplay(), consSuffix, storeType}\n\tmsg := fmt.Sprintf(logInstallingStateStoreProviderStartMessageHuman, params...)\n\ts.log(msg)\n}\n\n// Implements StateStoreProviderTrustLogger interface.\nfunc (s *StateMigrateHuman) LogInteractiveApproval() {\n\ts.log(logInteractiveApprovalMessageHuman)","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/views/state_migrate.go#L154-L190","documentation":"StateMigrateHuman.Output (internal/command/views/state_migrate.go:166, implementing ProviderInstallationLogger) looks up the human message for a given InitMessageCode in the shared MessageRegistry (defined in internal/command/views/init.go:495). If the code is absent from the registry it panics 'missing message for InstallingProviderMessage init message code'.","triggerScenarios":"Output is called with an InitMessageCode value not present in MessageRegistry — e.g. a new InitMessageCode constant added to init.go without a corresponding registry entry, or a caller passing an arbitrary/empty string cast as InitMessageCode.","commonSituations":"Adding a provider-install lifecycle message during state migration and forgetting to register it; a refactor that moves codes without moving registry entries; a typo when constructing the code.","solutions":["Whenever you add a new InitMessageCode constant, add its InitMessage (HumanValue) to MessageRegistry in internal/command/views/init.go in the same commit.","Search for all InitMessageCode constants and diff them against MessageRegistry keys to find unregistered codes.","Add a unit test that iterates every InitMessageCode constant and asserts MessageRegistry[code] exists.","As an end user this is an internal bug — report it with the state-migrate/init operation that triggered the panic."],"exampleFix":"// before\nmsg, ok := MessageRegistry[code]\nif !ok {\n    panic(\"missing message for InstallingProviderMessage init message code\")\n}\n\n// after (no-op + log instead of crashing)\nmsg, ok := MessageRegistry[code]\nif !ok {\n    log.Printf(\"[WARN] no message registered for init message code %q\", code)\n    return\n}","handlingStrategy":"validation","validationCode":"// Validate the code is registered before calling Output.\nfunc isRegistered(code views.InitMessageCode) bool {\n    _, ok := views.MessageRegistry[code]\n    return ok\n}\nif !isRegistered(code) {\n    return fmt.Errorf(\"unregistered init message code %q\", code)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never construct InitMessageCode from arbitrary strings; only use the named constants in init.go.","When adding an InitMessageCode constant, add its MessageRegistry entry in the same change.","Add an init-time or test-time assertion that every declared InitMessageCode has a registry entry."],"tags":["panic","message-registry","exhaustive-switch","state-migrate","provider-install","internal-bug"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}