{"record":{"id":"148b71aca0984ceb","repo":"kubernetes/kops","slug":"error-building-iam-policy-w","errorCode":null,"errorMessage":"error building IAM policy: %w","messagePattern":"error building IAM policy: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/iam.go","lineNumber":375,"sourceCode":"\n\t\t\t\tadditionalPolicyName := \"additional.\" + iamName\n\n\t\t\t\tt := &awstasks.IAMRolePolicy{\n\t\t\t\t\tName:      new(additionalPolicyName),\n\t\t\t\t\tLifecycle: b.Lifecycle,\n\n\t\t\t\t\tRole: iamRole,\n\t\t\t\t}\n\n\t\t\t\tif additionalPolicy != \"\" {\n\t\t\t\t\tp, err := b.buildPolicy(additionalPolicy)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"additionalPolicy %q is invalid: %v\", roleKey, err)\n\t\t\t\t\t}\n\n\t\t\t\t\tpolicy, err := p.AsJSON()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"error building IAM policy: %w\", err)\n\t\t\t\t\t}\n\n\t\t\t\t\tt.PolicyDocument = fi.NewStringResource(policy)\n\t\t\t\t} else {\n\t\t\t\t\tt.PolicyDocument = fi.NewStringResource(\"\")\n\t\t\t\t}\n\n\t\t\t\tc.AddTask(t)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (b *IAMModelBuilder) buildPolicy(policyString string) (*iam.Policy, error) {\n\tp := &iam.Policy{\n\t\tVersion: iam.PolicyDefaultVersion,","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/iam.go#L357-L393","documentation":"Serializing an assembled IAM policy document to JSON failed while building additional role policies; a json.Marshal failure over the parsed statements, normally indicating an unmarshalable field within a statement.","triggerScenarios":"Thrown at pkg/model/awsmodel/iam.go:375 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the additionalPolicy content in the instance group for unusual constructs","Simplify the additional policy JSON and retry","Report as a bug if the policy is valid AWS JSON"],"exampleFix":null,"handlingStrategy":"try-catch","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"}