kubernetes/kops · error

error parsing configuration: %v

Error message

error parsing configuration: %v

What it means

ParseRawYaml unmarshals a YAML document into dest using sigs.k8s.io/yaml with yaml.DisallowUnknownFields. Any syntax error in the YAML, or any field in the document that does not exist on the destination struct, produces this wrapped error. The inner %v carries the precise yaml error (line number and offending field).

Source

Thrown at pkg/apis/kops/parse.go:66

	if lenient && strings.ToLower(findRole) == "master" {
		return InstanceGroupRoleControlPlane, true
	}

	return "", false
}

// ParseRawYaml parses an object just using yaml, without the full api machinery
// Deprecated: prefer using the API machinery (package kopscodecs)
func ParseRawYaml(data []byte, dest interface{}) error {
	// Yaml can't parse empty strings
	configString := string(data)
	configString = strings.TrimSpace(configString)

	if configString != "" {
		err := yaml.Unmarshal([]byte(configString), dest, yaml.DisallowUnknownFields)
		if err != nil {
			return fmt.Errorf("error parsing configuration: %v", err)
		}
	}

	return nil
}

// ToRawYaml marshals an object to yaml, without the full api machinery
// Deprecated: prefer using the API machinery (package kopscodecs)
func ToRawYaml(obj interface{}) ([]byte, error) {
	data, err := utils.YamlMarshal(obj)
	if err != nil {
		return nil, fmt.Errorf("error converting to yaml: %v", err)
	}

	return data, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the inner error message (%v) — it names the exact line and field; fix that line in the YAML file.
  2. Replace tabs with spaces and fix indentation of the offending block.
  3. Remove or correct misspelled/unknown fields; check `kops get cluster -o yaml` for the accepted schema.
  4. If caused by a kOps upgrade, migrate the manifest to the current API fields or pin the older kOps version.

Example fix

// before
spec:
	encryptionConfig: true   # tab indentation -> parse error
// after
spec:
  encryptionConfig: true
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate YAML before ParseRawYaml
var probe map[string]interface{}
if err := yaml.Unmarshal(data, &probe); err != nil {
	return fmt.Errorf("invalid YAML: %w", err)
}

Try / catch

if err := kops.ParseRawYaml(data, dest); err != nil {
	var detail string
	fmt.Sscanf(err.Error(), "error parsing configuration: %s", &detail)
	log.Fatalf("config file invalid, fix this first: %s", detail)
}

Prevention

When it happens

Trigger: Calling ParseRawYaml (or its callers ParseChannel, RunCreateSecretEncryptionConfig, RunCreateSecretCiliumEncryptionConfig) with: (1) malformed YAML — bad indentation, tabs, unbalanced quotes; (2) an unknown/misspelled field in the document; (3) a type mismatch (string where int is expected).

Common situations: Editing a kops channel or encryptionconfig manifest by hand and introducing an indentation slip; upgrading kOps where a field was renamed/removed so old manifests now contain unknown fields; copying examples with tabs instead of spaces; pasting config from another tool with extra fields.

Related errors


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