{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/jsonformat/structured/attribute_path/matcher.go#L146-L182","documentation":"A panic in PathMatcher.GetChildWithKey: a path element is neither a string nor a float64. JSON-decoded paths should only contain strings (attribute names) and numbers (indices); any other type means upstream path validation failed. The message explicitly states this is a Terraform bug and asks for a report.","triggerScenarios":"Calling GetChildWithKey with a Paths slice containing a bool, nil, map, or slice element — possible only if the path was not normalized through the standard JSON unmarshaling/validation (which produces string/float64). Triggered during sensitive-attribute path matching in JSON plan/state rendering.","commonSituations":"Internal Terraform bug in path handling; custom/buggy callers passing non-canonical paths; corruption during JSON decoding of sensitive_paths.","solutions":["Report the bug to Terraform with the config, plan, and state that triggered it — this path should be unreachable.","As a workaround, regenerate the plan/state from a clean `terraform init && terraform plan`.","Update to the latest Terraform patch release; the bug may already be fixed."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Sanitize a decoded path so only string/float64 elements remain.\nfunc sanitizePath(p []any) []any {\n    out := make([]any, 0, len(p))\n    for _, e := range p {\n        switch e.(type) {\n        case string, float64: out = append(out, e)\n        }\n    }\n    return out\n}","typeGuard":"func isCanonicalPathElement(v any) bool {\n    switch v.(type) {\n    case string, float64: return true\n    default: return false\n    }\n}","tryCatchPattern":null,"preventionTips":["Report the panic as a Terraform bug with plan/state attached.","Regenerate plans from a clean init to avoid corrupted sensitive paths.","Keep Terraform updated; path-validation fixes land in patch releases."],"tags":["terraform-internal","jsonformat","panic","attribute-path","bug"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}