{"record":{"id":"d56ea54e40983c08","repo":"argoproj/argo-workflows","slug":"key-was-not-found-for-s","errorCode":null,"errorMessage":"key was not found for %s","messagePattern":"key was not found for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apis/workflow/v1alpha1/workflow_types.go","lineNumber":2030,"sourceCode":"func (n Nodes) Any(f func(NodeStatus) bool) bool {\n\treturn n.Find(f) != nil\n}\n\nfunc (n Nodes) Find(f func(NodeStatus) bool) *NodeStatus {\n\tfor _, i := range n {\n\t\tif f(i) {\n\t\t\treturn &i\n\t\t}\n\t}\n\treturn nil\n}\n\n// Get a NodeStatus from the hashmap of Nodes.\n// Return a nil along with an error if non existent.\nfunc (n Nodes) Get(key string) (*NodeStatus, error) {\n\tval, ok := n[key]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"key was not found for %s\", key)\n\t}\n\treturn &val, nil\n}\n\n// Has checks if the Nodes map has a key entry.\nfunc (n Nodes) Has(key string) bool {\n\t_, err := n.Get(key)\n\treturn err == nil\n}\n\n// GetPhase returns the Phase of a Node by key.\nfunc (n Nodes) GetPhase(key string) (*NodePhase, error) {\n\tval, err := n.Get(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &val.Phase, nil\n}","sourceCodeStart":2012,"sourceCodeEnd":2048,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/pkg/apis/workflow/v1alpha1/workflow_types.go#L2012-L2048","documentation":"Nodes is a map of node ID to NodeStatus on WorkflowStatus. The Get helper returns a pointer to the node status, and when the requested key (node ID) is not present in the map it returns this error naming the missing key, rather than a nil pointer.","triggerScenarios":"Calling wf.Status.Nodes.Get(nodeID) with a node ID that does not exist — e.g. a stale/incorrect nodeID, querying before the workflow has started, or after node status was truncated/offloaded.","commonSituations":"Looking up a child node ID from an old generation of the workflow; offline archive readers using node IDs not present in the (possibly compressed) status; typo'd or fabricated node IDs in custom controllers.","solutions":["Verify the nodeID exists with Nodes.Has(nodeID) before calling Get","Re-fetch/hydrate the Workflow object — node status may be offloaded or from a stale copy","Use the correct node ID obtained from the workflow's Nodes map (list keys) instead of constructing one"],"exampleFix":"// before\nnode, err := wf.Status.Nodes.Get(nodeID) // error if absent\n// after\nif !wf.Status.Nodes.Has(nodeID) {\n    return fmt.Errorf(\"node %s not present\", nodeID)\n}\nnode, err := wf.Status.Nodes.Get(nodeID)","handlingStrategy":"type-guard","validationCode":"if nodeID == \"\" || !wf.Status.Nodes.Has(nodeID) {\n    return errors.New(\"node does not exist in workflow status\")\n}","typeGuard":"func nodeExists(n Nodes, id string) bool {\n    return n.Has(id)\n}","tryCatchPattern":"node, err := wf.Status.Nodes.Get(nodeID)\nif err != nil {\n    return fmt.Errorf(\"node %s not found (workflow may have been retried or status offloaded): %w\", nodeID, err)\n}","preventionTips":["Always check Nodes.Has() before Get","Re-fetch the Workflow instead of caching Nodes across reconciles","Never construct node IDs manually; read them from Status.Nodes"],"tags":["workflow-status","nodes","map-lookup"],"backgroundTag":"node-not-found","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"}