{"record":{"id":"306d9a9bd6e4a402","repo":"argoproj/argo-workflows","slug":"expected-exactly-one-key-got-d","errorCode":null,"errorMessage":"expected exactly one key, got %d","messagePattern":"expected exactly one key, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apis/workflow/v1alpha1/plugin_types.go","lineNumber":27,"sourceCode":"type Plugin struct {\n\t// +kubebuilder:pruning:PreserveUnknownFields\n\tObject `json:\",inline\" protobuf:\"bytes,1,opt,name=object\"`\n}\n\n// UnmarshalJSON unmarshalls the Plugin from JSON, and also validates that it is a map exactly one key\nfunc (p *Plugin) UnmarshalJSON(value []byte) error {\n\tif err := p.Object.UnmarshalJSON(value); err != nil {\n\t\treturn err\n\t}\n\t// by validating the structure in UnmarshallJSON, we prevent bad data entering the system at the point of\n\t// parsing, which means we do not need validate\n\tm := map[string]any{}\n\tif err := json.Unmarshal(p.Value, &m); err != nil {\n\t\treturn err\n\t}\n\tnumKeys := len(m)\n\tif numKeys != 1 {\n\t\treturn fmt.Errorf(\"expected exactly one key, got %d\", numKeys)\n\t}\n\treturn nil\n}\n","sourceCodeStart":9,"sourceCodeEnd":31,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/pkg/apis/workflow/v1alpha1/plugin_types.go#L9-L31","documentation":"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.","triggerScenarios":"Thrown at pkg/apis/workflow/v1alpha1/plugin_types.go:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the plugin manifest/object a single top-level key mapping to the plugin spec"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}