{"record":{"id":"f69839128ddc3395","repo":"docker/cli","slug":"key-s-doesn-t-exist-in-node-s-labels","errorCode":null,"errorMessage":"key %s doesn't exist in node's labels","messagePattern":"key (.+?) doesn't exist in node's labels","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/node/update.go","lineNumber":113,"sourceCode":"\t\t\tstr, err := flags.GetString(flagAvailability)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tspec.Availability = swarm.NodeAvailability(str)\n\t\t}\n\t\tif spec.Annotations.Labels == nil {\n\t\t\tspec.Annotations.Labels = make(map[string]string)\n\t\t}\n\t\tif flags.Changed(flagLabelAdd) {\n\t\t\tlabels := flags.Lookup(flagLabelAdd).Value.(*opts.ListOpts).GetSlice()\n\t\t\tmaps.Copy(spec.Annotations.Labels, opts.ConvertKVStringsToMap(labels))\n\t\t}\n\t\tif flags.Changed(flagLabelRemove) {\n\t\t\tkeys := flags.Lookup(flagLabelRemove).Value.(*opts.ListOpts).GetSlice()\n\t\t\tfor _, k := range keys {\n\t\t\t\t// if a key doesn't exist, fail the command explicitly\n\t\t\t\tif _, exists := spec.Annotations.Labels[k]; !exists {\n\t\t\t\t\treturn fmt.Errorf(\"key %s doesn't exist in node's labels\", k)\n\t\t\t\t}\n\t\t\t\tdelete(spec.Annotations.Labels, k)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n}\n\nconst (\n\tflagRole         = \"role\"\n\tflagAvailability = \"availability\"\n\tflagLabelAdd     = \"label-add\"\n\tflagLabelRemove  = \"label-rm\"\n)\n","sourceCodeStart":95,"sourceCodeEnd":128,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/node/update.go#L95-L128","documentation":"Returned by mergeNodeUpdate (node/update.go:113) when --label-rm references a key that is absent from the node's current Spec.Annotations.Labels. The CLI deliberately fails the command rather than silently no-oping, so operators know exactly which key was not found.","triggerScenarios":"Running `docker node update --label-rm <key> NODE` where <key> was never set on NODE, or was already removed in a prior update. The check is a literal map lookup at update.go:112.","commonSituations":"Typo in the label key, case mismatch (labels are case-sensitive), attempting to remove a label that was set via the API with a different name, or scripting a cleanup that assumes labels exist.","solutions":["Inspect the node first (`docker node inspect NODE`) and copy the exact label key.","Correct typos or casing in the --label-rm argument.","If the label genuinely should be gone, treat its absence as success and drop the flag from your script."],"exampleFix":"// before\ndocker node update --label-rm gpu NODE   // actual label is GPU\n// after\ndocker node update --label-rm GPU NODE","handlingStrategy":"validation","validationCode":"// Inspect the node and confirm each removal key exists before calling update.\nfunc nodeHasLabels(ctx context.Context, c client.NodeAPIClient, nodeID string, keys []string) error {\n    res, err := c.NodeInspectWithRaw(ctx, nodeID)\n    if err != nil { return err }\n    labels := res.Node.Spec.Annotations.Labels\n    for _, k := range keys {\n        if _, ok := labels[k]; !ok {\n            return fmt.Errorf(\"key %s doesn't exist in node's labels\", k)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `docker node inspect` and copy exact label keys (they are case-sensitive).","In scripts, fetch current labels and diff before issuing removals.","Treat a missing-key removal as idempotent success if that matches your intent."],"tags":["node","swarm","labels","docker-cli"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}