{"record":{"id":"340124c054c50494","repo":"hashicorp/terraform","slug":"unsupported-variable-option-name-q-this-is-a-bug","errorCode":null,"errorMessage":"unsupported variable option name %q (this is a bug in Terraform)","messagePattern":"unsupported variable option name %q \\(this is a bug in Terraform\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/arguments/vars.go","lineNumber":178,"sourceCode":"\t\t\t\t\tfmt.Sprintf(\"Variable name %q is invalid due to trailing space. Did you mean -var=\\\"%s=%s\\\"?\", name, strings.TrimSuffix(name, \" \"), strings.TrimPrefix(rawVal, \" \")),\n\t\t\t\t))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tret[name] = unparsedVariableValueString{\n\t\t\t\tstr:        rawVal,\n\t\t\t\tname:       name,\n\t\t\t\tsourceType: terraform.ValueFromCLIArg,\n\t\t\t}\n\n\t\tcase \"-var-file\":\n\t\t\tvarsFromFile, moreDiags := addVarsFromFile(flagNameValue.Value, terraform.ValueFromNamedFile, onFileLoad)\n\t\t\tmaps.Copy(ret, varsFromFile)\n\t\t\tdiags = diags.Append(moreDiags)\n\n\t\tdefault:\n\t\t\t// Should never happen; always a bug in the code that built up\n\t\t\t// the contents of m.variableArgs.\n\t\t\tdiags = diags.Append(fmt.Errorf(\"unsupported variable option name %q (this is a bug in Terraform)\", flagNameValue.Name))\n\t\t}\n\t}\n\n\treturn ret, diags\n}\n\nfunc CollectValuesForTests(testsFilePath string, onFileLoad func(filename string, src []byte)) (map[string]UnparsedVariableValue, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n\tret := map[string]UnparsedVariableValue{}\n\n\t// We collect the variables from the ./tests directory\n\t// there is no other need to process environmental variables\n\t// as this is done via collectVariableValues function\n\tif testsFilePath == \"\" {\n\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Warning,\n\t\t\t\"Missing test directory\",\n\t\t\t\"The test directory was unspecified when it should always be set. This is a bug in Terraform - please report it.\"))","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/arguments/vars.go#L160-L196","documentation":"An internal assertion error in the default case of a switch over variable flag names during collectVariableValues. The source comment states this should never happen and indicates a bug in the code that built m.variableArgs. This is not a user-facing configuration error but a Terraform internal programming defect.","triggerScenarios":"The default case in the switch over flagNameValue.Name is reached during collectVariableValues. This would only happen if the code populating m.variableArgs introduced a new -var-related flag name without adding a corresponding case to this switch.","commonSituations":"This should never occur in released versions. If seen, it indicates a code regression during Terraform development where a new variable-related flag was added to the args map without updating the consumer switch.","solutions":["Report a bug to the Terraform project at github.com/hashicorp/terraform/issues with the full command and version","Downgrade to a known-stable Terraform version if this appeared after an upgrade","If developing Terraform: add the missing case to the switch in internal/command/arguments/vars.go"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// This error is an internal bug; wrap terraform invocation and surface it clearly\nout, err := cmd.CombinedOutput()\nif err != nil {\n    if strings.Contains(string(out), \"this is a bug in Terraform\") {\n        log.Fatal(\"internal Terraform bug detected; please report at \" +\n            \"github.com/hashicorp/terraform/issues with the command and version\")\n    }\n}","preventionTips":["Pin Terraform to a stable released version in production","Monitor for regression when upgrading Terraform versions","Report internal bug errors upstream immediately with full command context"],"tags":["internal-bug","assertion","variables","unreachable"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}