{"record":{"id":"566132ec359de996","repo":"hashicorp/nomad","slug":"missing-required-meta-object","errorCode":null,"errorMessage":"missing required Meta object","messagePattern":"missing required Meta object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/node.go","lineNumber":496,"sourceCode":"\tScheduleState TaskScheduleState\n}\n\n// NodeMetaApplyRequest is used to update Node metadata on Client agents.\ntype NodeMetaApplyRequest struct {\n\tQueryOptions // Client RPCs must use QueryOptions to set AllowStale=true\n\n\t// NodeID is the node being targeted by this request (or the node\n\t// receiving this request if NodeID is empty).\n\tNodeID string\n\n\t// Meta is the new Node metadata being applied and differs slightly\n\t// from Node.Meta as nil values are used to unset Node.Meta keys.\n\tMeta map[string]*string\n}\n\nfunc (n *NodeMetaApplyRequest) Validate() error {\n\tif len(n.Meta) == 0 {\n\t\treturn fmt.Errorf(\"missing required Meta object\")\n\t}\n\tfor k := range n.Meta {\n\t\tif k == \"\" {\n\t\t\treturn fmt.Errorf(\"metadata keys must not be empty\")\n\t\t}\n\n\t\t// Validate keys are dotted identifiers since their primary use case is in\n\t\t// constraints as interpolated hcl variables.\n\t\t// https://github.com/hashicorp/hcl/blob/v2.16.0/hclsyntax/spec.md#identifiers\n\t\tfor part := range strings.SplitSeq(k, \".\") {\n\t\t\tif !hclsyntax.ValidIdentifier(part) {\n\t\t\t\treturn fmt.Errorf(\"%q is invalid; metadata keys must be valid dotted hcl identifiers\", k)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/node.go#L478-L514","documentation":"NodeMetaApplyRequest.Validate enforces that a node metadata update actually carries a Meta map; an empty map (len == 0) is rejected with \"missing required Meta object\". Nomad requires at least one key so an update request can't be a no-op or an accidental wipe via empty payload.","triggerScenarios":"Calling the node metadata update API (e.g. Client().Nodes().UpdateMeta) with a NodeMetaApplyRequest whose Meta map is nil or empty.","commonSituations":"Script building the request from an empty env/config map; CLI/API client serializing no changes; accidental omission of meta flags in automation.","solutions":["Populate request.Meta with at least one key/value pair before submitting.","Check upstream inputs: if nothing changed, skip the API call instead of sending an empty request.","For deleting keys, include them with nil values rather than sending an empty map."],"exampleFix":"// before\nreq := &structs.NodeMetaApplyRequest{Meta: map[string]*string{}}\n// after\nreq := &structs.NodeMetaApplyRequest{Meta: map[string]*string{\"env\": strPtr(\"prod\")}}","handlingStrategy":"validation","validationCode":"func validateMetaReq(req *structs.NodeMetaApplyRequest) error {\n  if req == nil || len(req.Meta) == 0 {\n    return errors.New(\"node meta update requires at least one key\")\n  }\n  return nil\n}","typeGuard":"func hasMeta(m map[string]*string) bool { return len(m) > 0 }","tryCatchPattern":"null","preventionTips":["Skip the update call entirely when the computed diff is empty","Represent deletions as keys with nil values, never an empty map","Unit-test automation that builds NodeMetaApplyRequest payloads"],"tags":["nomad","validation","node-metadata","api"],"backgroundTag":"missing-required-argument","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}