{"record":{"id":"7f887261c99f3bc7","repo":"hashicorp/nomad","slug":"missing-datacenter-for-client-registration","errorCode":null,"errorMessage":"missing datacenter for client registration","messagePattern":"missing datacenter for client registration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"nomad/structs/node.go","lineNumber":606,"sourceCode":"\t// CreateNodePool is used to indicate that the node's node pool should be\n\t// created along with the node registration if it doesn't exist.\n\tCreateNodePool bool\n\n\tWriteRequest\n}\n\n// Validate checks that the NodeRegisterRequest is valid. Any returned error can\n// be sent back to the client as a response to the RPC call.\nfunc (n *NodeRegisterRequest) Validate() error {\n\n\tif n.Node == nil {\n\t\treturn errors.New(\"missing node for client registration\")\n\t}\n\tif n.Node.ID == \"\" {\n\t\treturn errors.New(\"missing node ID for client registration\")\n\t}\n\tif n.Node.Datacenter == \"\" {\n\t\treturn errors.New(\"missing datacenter for client registration\")\n\t}\n\tif n.Node.Name == \"\" {\n\t\treturn errors.New(\"missing node name for client registration\")\n\t}\n\tif len(n.Node.Attributes) == 0 {\n\t\treturn errors.New(\"missing attributes for client registration\")\n\t}\n\tif n.Node.SecretID == \"\" {\n\t\treturn errors.New(\"missing node secret ID for client registration\")\n\t}\n\tif n.Node.NodePool != \"\" {\n\t\tif err := ValidateNodePoolName(n.Node.NodePool); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid node pool: %v\", err)\n\t\t}\n\t\tif n.Node.NodePool == NodePoolAll {\n\t\t\treturn fmt.Errorf(\"node is not allowed to register in node pool %q\", NodePoolAll)\n\t\t}\n\t}","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/node.go#L588-L624","documentation":"NodeRegisterRequest.Validate returns this error when Node.Datacenter is empty. The datacenter is a required scheduling dimension in Nomad: jobs target datacenters, so a node without one cannot participate in placement and registration is rejected.","triggerScenarios":"Calling Node.Register with a Node struct whose Datacenter field is the empty string, usually because the client agent's datacenter config option was not set or was set to an empty value.","commonSituations":"Client agent config files missing the `datacenter` stanza in `client { ... }`; automation generating configs from templates with unfilled variables; operators migrating configs between environments and dropping the field.","solutions":["Set the `datacenter` option in the client agent configuration (e.g. client { datacenter = \"dc1\" }) and restart the agent.","In code constructing the request, assign Node.Datacenter to the correct DC name before calling Validate.","Add a config-load check that fails fast if the datacenter value is blank."],"exampleFix":"// before\nnode := &structs.Node{ID: id, Name: \"client-1\"}\n// after\nnode := &structs.Node{ID: id, Datacenter: \"dc1\", Name: \"client-1\"}","handlingStrategy":"validation","validationCode":"if node.Datacenter == \"\" {\n\treturn errors.New(\"datacenter must be configured for the client\")\n}","typeGuard":null,"tryCatchPattern":"if err := req.Validate(); err != nil {\n\tif strings.Contains(err.Error(), \"missing datacenter\") {\n\t\treturn fmt.Errorf(\"check client `datacenter` config: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Include `datacenter` in every client agent config template.","Lint agent configs for required client options before deploy.","Fail config load when required strings are blank."],"tags":["nomad","rpc","validation","config"],"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"}