{"record":{"id":"44167298f8ca8b44","repo":"hashicorp/terraform","slug":"found-invalid-type-within-path-v-t-the-valida","errorCode":null,"errorMessage":"found invalid type within path (%v:%T), the validation shouldn't have allowed this to happen; this is a bug in Terraform, please report it","messagePattern":"found invalid type within path \\((.+?):%T\\), the validation shouldn't have allowed this to happen; this is a bug in Terraform, please report it","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/command/jsonformat/structured/attribute_path/matcher.go","lineNumber":164,"sourceCode":"\t\t\t\tchild.Paths = append(child.Paths, path)\n\t\t\t}\n\n\t\t\t// If not we would simply drop this path from our set of paths but\n\t\t\t// either way we just continue.\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch val := path[0].(type) {\n\t\tcase string:\n\t\t\tif val == key {\n\t\t\t\tchild.Paths = append(child.Paths, path[1:])\n\t\t\t}\n\t\tcase float64:\n\t\t\t// here we must assume the path being looked up no longer matches\n\t\t\t// the given data structure, so the caller in incorrect. This is\n\t\t\t// fine, because it only means that we don't match any paths.\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"found invalid type within path (%v:%T), the validation shouldn't have allowed this to happen; this is a bug in Terraform, please report it\", val, val))\n\n\t\t}\n\t}\n\treturn child\n}\n\nfunc (p *PathMatcher) GetChildWithIndex(index int) Matcher {\n\tchild := &PathMatcher{\n\t\tPropagate: p.Propagate,\n\t}\n\tfor _, path := range p.Paths {\n\t\tif len(path) == 0 {\n\t\t\t// This means that the current value matched, but not necessarily\n\t\t\t// it's child.\n\n\t\t\tif p.Propagate {\n\t\t\t\t// If propagate is true, then our child match our matches\n\t\t\t\tchild.Paths = append(child.Paths, path)","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonformat/structured/attribute_path/matcher.go#L146-L182","documentation":"This is a panic (not a returned error) raised by PathMatcher.GetChildWithKey (matcher.go:154-164) when an element of a parsed attribute path is neither a string nor a float64. Paths are built from JSON unmarshalling of replace_paths / relevant_attributes, and validation elsewhere is expected to guarantee only those two types appear — so this panic signals an internal bug or corrupted path data.","triggerScenarios":"Rendering a plan/state diff whose ReplacePaths or RelevantAttributes contain a path element of an unexpected JSON type (e.g. bool, null, nested object/array) — which should have been rejected during the cty→JSON path conversion. Triggered via `terraform plan`/`show -json` rendering of resources with replace-due-to attributes.","commonSituations":"A bug in the jsonplan path conversion producing malformed path entries; feeding hand-crafted/edited plan JSON into the renderer; version mismatch between a plan produced by one terraform build and rendered by another; corrupted plan file.","solutions":["Re-run `terraform plan` to regenerate the plan/state with correctly-formed paths.","Report the panic to the Terraform project with the plan/config that reproduces it (the message explicitly asks for a bug report).","Ensure the same terraform binary/version produces and renders the plan (avoid cross-version plan files).","If editing plan JSON by hand, ensure every path element is a string or number."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Validate path elements are only string/float before handing them to the matcher.\nfor _, path := range paths {\n    for _, el := range path {\n        switch el.(type) {\n        case string, float64:\n        default:\n            return fmt.Errorf(\"invalid path element type %T; regenerate plan\", el)\n        }\n    }\n}","typeGuard":"// isValidPathElement narrows allowed attribute-path step types.\nfunc isValidPathElement(v interface{}) bool {\n    switch v.(type) {\n    case string, float64:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Never hand-edit plan JSON path arrays; keep every element a string or number.","Use one consistent terraform version to create and render plans.","Regenerate plans rather than reusing potentially-corrupted files."],"tags":["terraform-jsonformat","panic","attribute-path","internal-bug","plan-rendering"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}