argoproj/argo-workflows · error

expected exactly one key, got %d

Error message

expected exactly one key, got %d

What it means

Plugin.UnmarshalJSON validated the parsed plugin object and found it does not have exactly one top-level key. Plugin payloads must be a single-key map so the plugin name is unambiguous; any other shape is rejected at parse time.

Source

Thrown at pkg/apis/workflow/v1alpha1/plugin_types.go:27

type Plugin struct {
	// +kubebuilder:pruning:PreserveUnknownFields
	Object `json:",inline" protobuf:"bytes,1,opt,name=object"`
}

// UnmarshalJSON unmarshalls the Plugin from JSON, and also validates that it is a map exactly one key
func (p *Plugin) UnmarshalJSON(value []byte) error {
	if err := p.Object.UnmarshalJSON(value); err != nil {
		return err
	}
	// by validating the structure in UnmarshallJSON, we prevent bad data entering the system at the point of
	// parsing, which means we do not need validate
	m := map[string]any{}
	if err := json.Unmarshal(p.Value, &m); err != nil {
		return err
	}
	numKeys := len(m)
	if numKeys != 1 {
		return fmt.Errorf("expected exactly one key, got %d", numKeys)
	}
	return nil
}

View on GitHub (pinned to 35bff19146)

Solutions

  1. Make the plugin manifest/object a single top-level key mapping to the plugin spec
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/apis/workflow/v1alpha1/plugin_types.go:27 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/306d9a9bd6e4a402. Report an issue: GitHub.