{"record":{"id":"88a51b7f88450450","repo":"kubernetes/kops","slug":"field-q-in-s-was-not-an-object-was-t","errorCode":null,"errorMessage":"field %q in %s was not an object, was %T","messagePattern":"field %q in (.+?) was not an object, was %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/kubemanifest/manifest.go","lineNumber":233,"sourceCode":"\t\treturn \"\"\n\t}\n\treturn s\n}\n\n// Reparse parses a subfield from an object\nfunc (m *Object) Reparse(obj interface{}, fields ...string) error {\n\thumanFields := strings.Join(fields, \".\")\n\n\tcurrent := m.data\n\tfor _, field := range fields {\n\t\tv, found := current[field]\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"field %q in %s not found\", field, humanFields)\n\t\t}\n\n\t\tm, ok := v.(map[string]interface{})\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"field %q in %s was not an object, was %T\", field, humanFields, v)\n\t\t}\n\t\tcurrent = m\n\t}\n\n\tb, err := yaml.Marshal(current)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshaling %s to yaml: %v\", humanFields, err)\n\t}\n\n\tif err := yaml.Unmarshal(b, obj); err != nil {\n\t\treturn fmt.Errorf(\"error unmarshaling subobject %s: %v\", humanFields, err)\n\t}\n\n\treturn nil\n}\n\n// Set mutates a subfield to the newValue\nfunc (m *Object) Set(newValue interface{}, fieldPath ...string) error {","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/kubemanifest/manifest.go#L215-L251","documentation":"While walking the dotted field path, Reparse requires each intermediate value to be a map[string]interface{} so it can continue descending. If a segment exists but holds a scalar, list, or other non-object type, this error reports the field, full path, and the actual Go type found.","triggerScenarios":"Calling Reparse with a path where an intermediate segment is not a nested object — e.g. path spec.template on a manifest where template is a string, or path through a list-valued field (lists can't be traversed by map key).","commonSituations":"Wrong field path through schema versions where a field changed type; attempting to walk into arrays (e.g. spec.containers) which are slices, not maps; manifests produced by another tool with unexpected shapes.","solutions":["Adjust the fields path to stop before non-object segments (walk lists separately)","Verify the manifest schema/version matches the expected nesting","Filter objects to the intended kind before Reparse","Inspect the manifest's structure at the reported path (the error prints the actual %T)"],"exampleFix":"// before: path walks into a list\nobj.Reparse([]string{\"spec\",\"containers\"}, &v) // containers is []interface{}\n// after: reparse the pod spec level instead\nobj.Reparse([]string{\"spec\",\"template\",\"spec\"}, &podSpec)","handlingStrategy":"validation","validationCode":"func pathIsObject(obj *kubemanifest.Object, path ...string) bool {\n\tcur, _ := obj.ToJSONMap()\n\tfor i, f := range path {\n\t\tv, ok := cur[f]\n\t\tif !ok { return false }\n\t\tif i == len(path)-1 { return true } // last segment may be target struct\n\t\tm, ok := v.(map[string]interface{})\n\t\tif !ok { return false }\n\t\tcur = m\n\t}\n\treturn true\n}\n","typeGuard":"func isObjectMap(v interface{}) bool {\n\t_, ok := v.(map[string]interface{})\n\treturn ok\n}\n","tryCatchPattern":"err := obj.Reparse(fields, &target)\nif err != nil && strings.Contains(err.Error(), \"was not an object\") {\n\treturn fmt.Errorf(\"unexpected manifest shape at %v: %w\", fields, err)\n}\n","preventionTips":["Don't walk into list-typed fields with Reparse; handle slices separately","Match field paths to the manifest's schema version","Inspect the actual type printed in the error before changing paths","Test Reparse against representative manifests per kind"],"tags":["manifest","type-mismatch","path-navigation"],"backgroundTag":"manifest-field-type-mismatch","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}