{"record":{"id":"5899fe0ca6a13f16","repo":"hashicorp/nomad","slug":"invalid-status-for-node","errorCode":null,"errorMessage":"invalid status for node","messagePattern":"invalid status for node","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/node_endpoint.go","lineNumber":139,"sourceCode":"\t// value in state. This acts as a secondary check and can be seen as a\n\t// refresh token, in the event the identity is expired.\n\tif authErr != nil && !errors.Is(authErr, jwt.ErrExpired) {\n\t\treturn structs.ErrPermissionDenied\n\t}\n\n\tdefer metrics.MeasureSince([]string{\"nomad\", \"client\", \"register\"}, time.Now())\n\n\t// Perform validation of the base provided request.\n\tif err := args.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\t// Default the status if none is given\n\tif args.Node.Status == \"\" {\n\t\targs.Node.Status = structs.NodeStatusInit\n\t}\n\tif !structs.ValidNodeStatus(args.Node.Status) {\n\t\treturn fmt.Errorf(\"invalid status for node\")\n\t}\n\n\t// Default to eligible for scheduling if unset\n\tif args.Node.SchedulingEligibility == \"\" {\n\t\targs.Node.SchedulingEligibility = structs.NodeSchedulingEligible\n\t}\n\n\t// Default the node pool if none is given.\n\tif args.Node.NodePool == \"\" {\n\t\targs.Node.NodePool = structs.NodePoolDefault\n\t}\n\n\t// The current time is used at a number of places in the registration\n\t// workflow. Generating it once avoids multiple calls to time.Now() and also\n\t// means the same time is used across all checks and sets.\n\ttimeNow := time.Now()\n\n\t// Set the timestamp when the node is registered","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/node_endpoint.go#L121-L157","documentation":"The Node.Register handler defaults an empty node status to 'initializing', but if the client supplies a status string not in the valid set (initializing, pending, ready, down, disconnected), registration is rejected with 'invalid status for node'. This protects the state store from invalid status values.","triggerScenarios":"A Nomad client or custom API caller sends NodeRegisterRequest with Node.Status set to an unrecognized string such as 'up', 'active', or a value from an older/different Nomad version.","commonSituations":"Hand-rolled clients or agents built against an outdated Nomad API; autoscalers/provisioning tooling injecting a wrong default status; copying node JSON between clusters with modified fields.","solutions":["Omit Node.Status entirely and let the server default it to 'initializing'.","Set status to a valid value: initializing, pending, ready, down, or disconnected.","Upgrade the custom client/agent to match the server's Nomad version and its ValidNodeStatus vocabulary."],"exampleFix":"// before\nreq := &api.NodeRegisterRequest{Node: &api.Node{Status: \"active\"}}\n// after\nreq := &api.NodeRegisterRequest{Node: &api.Node{}} // server defaults to initializing\n// or explicitly:\nreq.Node.Status = \"ready\"","handlingStrategy":"validation","validationCode":"var validNodeStatuses = map[string]bool{\"initializing\": true, \"pending\": true, \"ready\": true, \"down\": true, \"disconnected\": true}\nif n.Status != \"\" && !validNodeStatuses[n.Status] {\n    return fmt.Errorf(\"invalid node status %q\", n.Status)\n}","typeGuard":"func isValidNodeStatus(s string) bool {\n    switch s {\n    case \"\", \"initializing\", \"pending\", \"ready\", \"down\", \"disconnected\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Omit Node.Status and let the server default it.","Only send statuses from the documented valid set.","Keep client agents and API callers on the same Nomad version as servers.","Add client-side enum validation mirroring structs.ValidNodeStatus."],"tags":["nomad","node-registration","validation"],"backgroundTag":"invalid-enum-value","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"}