{"record":{"id":"10a9f688e9c9d079","repo":"kubernetes/kops","slug":"expected-object-at-q-got-t","errorCode":null,"errorMessage":"expected object at %q, got %T","messagePattern":"expected object at %q, got %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/sqs.go","lineNumber":171,"sourceCode":"\tv, found := (*j)[key]\n\tif !found {\n\t\treturn nil, false, nil\n\t}\n\ts, ok := v.([]any)\n\tif !ok {\n\t\treturn nil, false, fmt.Errorf(\"expected slice at %q, got %T\", key, v)\n\t}\n\treturn s, true, nil\n}\n\nfunc (j *JSONObject) Object(key string) (JSONObject, bool, error) {\n\tv, found := (*j)[key]\n\tif !found {\n\t\treturn nil, false, nil\n\t}\n\tm, ok := v.(JSONObject)\n\tif !ok {\n\t\treturn nil, false, fmt.Errorf(\"expected object at %q, got %T\", key, v)\n\t}\n\treturn m, true, nil\n}\n\n// normalizePolicy sorts the Service principals in the policy, so that we can compare policies more easily.\nfunc normalizePolicy(policy map[string]interface{}) error {\n\txform := jsonutils.NewTransformer()\n\txform.AddSliceTransform(func(path string, value []any) ([]any, error) {\n\t\tif path != \".Statement[].Principal.Service[]\" {\n\t\t\treturn value, nil\n\t\t}\n\t\treturn jsonutils.SortSlice(value)\n\t})\n\tif err := xform.Transform(policy); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/sqs.go#L153-L189","documentation":"JSONObject.Object found the key present in the SQS policy document but holding a non-object value; normalization expected a nested JSON object (e.g. a Statement entry or Principal) at that key.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/awstasks/sqs.go:171 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the policy so the referenced key holds a JSON object","Use standard IAM policy shapes (Statement entries as objects unless arrays are expected)"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}