{"record":{"id":"9af22a4033db4f72","repo":"hashicorp/terraform","slug":"invalid-credentials-location-v","errorCode":null,"errorMessage":"invalid credentials location %#v","messagePattern":"invalid credentials location %#v","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/cliconfig/credentials.go","lineNumber":317,"sourceCode":"\tswitch loc := s.HostCredentialsLocation(host); loc {\n\tcase CredentialsInOtherFile:\n\t\treturn ErrUnwritableHostCredentials(host)\n\tcase CredentialsInPrimaryFile, CredentialsNotAvailable:\n\t\t// If the host already has credentials stored locally then we'll update\n\t\t// them locally too, even if there's a credentials helper configured,\n\t\t// because the user might be intentionally retaining this particular\n\t\t// host locally for some reason, e.g. if the credentials helper is\n\t\t// talking to some shared remote service like HashiCorp Vault.\n\t\treturn s.updateLocalHostCredentials(host, new)\n\tcase CredentialsViaHelper:\n\t\t// Delegate entirely to the helper, then.\n\t\tif new == nil {\n\t\t\treturn s.helper.ForgetForHost(host)\n\t\t}\n\t\treturn s.helper.StoreForHost(host, new)\n\tdefault:\n\t\t// Should never happen because the above cases are exhaustive\n\t\treturn fmt.Errorf(\"invalid credentials location %#v\", loc)\n\t}\n}\n\nfunc (s *CredentialsSource) updateLocalHostCredentials(host svchost.Hostname, new svcauth.HostCredentialsWritable) error {\n\t// This function updates the local credentials file in particular,\n\t// regardless of whether a credentials helper is active. It should be\n\t// called only indirectly via updateHostCredentials.\n\n\tfilename, err := s.CredentialsFilePath()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to determine credentials file path: %s\", err)\n\t}\n\n\toldSrc, err := ioutil.ReadFile(filename)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"cannot read %s: %s\", filename, err)\n\t}\n","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/cliconfig/credentials.go#L299-L335","documentation":"An internal assertion error in the default case of a switch over credentials location types (CredentialsLocation) in updateHostCredentials. The source comment states the above cases (CredentialsInOtherFile, CredentialsInPrimaryFile/CredentialsNotAvailable, CredentialsViaHelper) are exhaustive, so reaching this default is a Terraform bug indicating an unexpected enum value.","triggerScenarios":"updateHostCredentials switches on s.HostCredentialsLocation(host) and the default case is reached, meaning a CredentialsLocation value outside the known set (0='P', 'O', 'H') was returned. This would only happen if a new CredentialsLocation variant was added without updating this switch.","commonSituations":"Should never happen in production. If seen, it indicates a code regression where a new CredentialsLocation constant was introduced without updating the exhaustive switch in updateHostCredentials.","solutions":["Report a bug to the Terraform project at github.com/hashicorp/terraform/issues with the full error and version","Downgrade to a stable version if this appeared after an upgrade","If developing Terraform: add the missing case to the switch in internal/command/cliconfig/credentials.go"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// This is an internal bug; surface it clearly in automation\nif strings.Contains(stderr, \"invalid credentials location\") {\n    return fmt.Errorf(\"internal Terraform bug: please report at github.com/hashicorp/terraform/issues\")\n}","preventionTips":["Pin Terraform to stable released versions","Report internal assertion errors upstream with full context","Monitor for regressions after version upgrades","Add error-detection wrappers in automation that flag 'bug' messages for escalation"],"tags":["internal-bug","assertion","credentials","unreachable"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}