kubernetes/kops · error

error parsing IAM statements: %v

Error message

error parsing IAM statements: %v

What it means

ParseStatements failed to unmarshal a user-supplied IAM policy string as a JSON array of Statement objects; the additionalPolicy JSON is malformed, or it is a whole-document object rather than an array of statements.

Source

Thrown at pkg/model/iam/types.go:35

package iam

import (
	"encoding/json"
	"fmt"
	"strings"

	"k8s.io/kops/pkg/apis/kops"
	"k8s.io/kops/pkg/truncate"
)

// MaxLengthIAMRoleName defines the max length of an IAMRole name
const MaxLengthIAMRoleName = 64

// ParseStatements parses JSON into a list of Statements
func ParseStatements(policy string) ([]*Statement, error) {
	statements := make([]*Statement, 0)
	if err := json.Unmarshal([]byte(policy), &statements); err != nil {
		return nil, fmt.Errorf("error parsing IAM statements: %v", err)
	}
	return statements, nil
}

type IAMModelContext struct {
	// AWSAccountID holds the 12 digit AWS account ID, when running on AWS
	AWSAccountID string
	// AWSPartition defines the partition of the AWS account, typically "aws", "aws-cn", or "aws-us-gov"
	AWSPartition string

	// Cluster holds the cluster we are working with.
	Cluster *kops.Cluster
}

// IAMNameForServiceAccountRole determines the name of the IAM Role and Instance Profile to use for the service-account role
func (b *IAMModelContext) IAMNameForServiceAccountRole(role Subject) (string, error) {
	serviceAccount, ok := role.ServiceAccount()
	if !ok {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Validate the additionalPolicy JSON — it must be an array of Statement objects
  2. Wrap the statements in [ ... ] if a bare object was supplied
  3. Run the policy through a JSON linter before applying
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/model/iam/types.go:35 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/dab1961c66796626. Report an issue: GitHub.