{"record":{"id":"e6325002a5d4bdc7","repo":"kubernetes/kops","slug":"error-marshaling-policy-to-json-v","errorCode":null,"errorMessage":"error marshaling policy to JSON: %v","messagePattern":"error marshaling policy to JSON: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/iam/iam_builder.go","lineNumber":191,"sourceCode":"\t\t\t},\n\t\t})\n\t\t// ec2:CreateSecurityGroup needs some special care as it also interacts with vpc, which do not support RequestTag.\n\t\t// We also do not require VPCs to be tagged, so we are not sending any conditions, allowing SGs to be created in any VPC.\n\t\tif p.clusterTaggedCreateAction.Has(\"ec2:CreateSecurityGroup\") {\n\t\t\tstatements = append(statements, &Statement{\n\t\t\t\tEffect:   StatementEffectAllow,\n\t\t\t\tAction:   stringorset.Of(\"ec2:CreateSecurityGroup\"),\n\t\t\t\tResource: stringorset.String(fmt.Sprintf(\"arn:%s:ec2:*:*:vpc/*\", p.partition)),\n\t\t\t})\n\t\t}\n\t}\n\tif len(statements) == 0 {\n\t\treturn \"\", nil\n\t}\n\n\tj, err := json.MarshalIndent(&Policy{Statement: statements, Version: p.Version}, \"\", \"  \")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error marshaling policy to JSON: %v\", err)\n\t}\n\treturn string(j), nil\n}\n\n// StatementEffect is required and specifies what type of access the statement results in\ntype StatementEffect string\n\n// StatementEffectAllow allows access for the given resources in the statement (based on conditions)\nconst StatementEffectAllow StatementEffect = \"Allow\"\n\n// StatementEffectDeny allows access for the given resources in the statement (based on conditions)\nconst StatementEffectDeny StatementEffect = \"Deny\"\n\n// Condition is a map of Conditions to be evaluated for a given IAM Statement\ntype Condition map[string]interface{}\n\n// Statement is an AWS IAM Policy Statement Object:\n// http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Statement","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/iam/iam_builder.go#L173-L209","documentation":"json.Marshal of the assembled IAM policy statements failed inside AsJSON; with the statement types used this is effectively an internal error — an unmarshalable field value slipped into a statement.","triggerScenarios":"Thrown at pkg/model/iam/iam_builder.go:191 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report as a bug with the cluster's IAM configuration","Check for unusual values in additionalPolicies","Simplify the additional policy content"],"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"}