kubernetes/kops · error

marshalling nodeupConfig: %w

Error message

marshalling nodeupConfig: %w

What it means

After GetBootstrapData succeeds, getNodeConfig serializes bootstrapData.NodeupConfig to JSON for embedding in NodeConfig. This error means json.Marshal failed on that structure, which is nearly impossible for ordinary data and indicates an invalid value in the config graph (e.g. invalid custom fields).

Source

Thrown at cmd/kops-controller/pkg/server/node_config.go:92

		p := s.configBase.Join("igconfig", "node", instanceGroupName, "nodeupconfig.yaml")

		b, err := p.ReadFile(ctx)
		if err != nil {
			return nil, fmt.Errorf("error loading NodeupConfig %q: %v", p, err)
		}
		nodeConfig = &nodeup.NodeConfig{}
		nodeConfig.NodeupConfig = string(b)
	}

	if nodeConfig == nil {
		bootstrapData, err := configBuilder.GetBootstrapData(ctx)
		if err != nil {
			return nil, fmt.Errorf("building nodeConfig for instanceGroup: %w", err)
		}
		nodeupConfig, err := json.Marshal(bootstrapData.NodeupConfig)
		if err != nil {
			return nil, fmt.Errorf("marshalling nodeupConfig: %w", err)
		}
		nodeConfig = &nodeup.NodeConfig{}
		nodeConfig.NodeupConfig = string(nodeupConfig)
	}

	{
		secretIDs := []string{
			"dockerconfig",
		}
		nodeConfig.NodeSecrets = make(map[string][]byte)
		for _, id := range secretIDs {
			secret, err := s.secretStore.FindSecret(id)
			if err != nil {
				return nil, fmt.Errorf("error loading secret %q: %w", id, err)
			}
			if secret != nil && secret.Data != nil {
				nodeConfig.NodeSecrets[id] = secret.Data
			}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Log the wrapped marshal error for the offending field
  2. Check for recent kOps version changes or custom patches to NodeupConfig
  3. Regenerate nodeup config via kops update cluster
  4. Report to kOps maintainers with the wrapped error
Defensive patterns

Strategy: try-catch

Try / catch

cfg, err := json.Marshal(bootstrapData.NodeupConfig)
if err != nil {
    return nil, fmt.Errorf("marshalling nodeupConfig: %w", err)
}

Prevention

When it happens

Trigger: json.Marshal(bootstrapData.NodeupConfig) returns an error, only possible if NodeupConfig contains unsupported values (e.g. NaN-like numbers via custom types, channels/funcs in unmarshalable custom fields).

Common situations: A kOps version regression or custom nodeup config field introduced unserializable data; corrupted cluster state decoded into an invalid struct.

Understand the failure class

Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.

Related errors


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