{"record":{"id":"5a26821633be8c9b","repo":"hashicorp/nomad","slug":"missing-job-for-registration","errorCode":null,"errorMessage":"missing job for registration","messagePattern":"missing job for registration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/job_endpoint.go","lineNumber":123,"sourceCode":"\t\treturn err\n\t}\n\n\tallowedPermissions := []string{acl.NamespaceCapabilityRegisterJob}\n\n\treturn j.doRegister(aclObj, allowedPermissions, args, reply)\n}\n\n// doRegister does the actual job registration, including any additional\n// permission checks, and after metrics have begun recording\nfunc (j *Job) doRegister(aclObj *acl.ACL, additionalAllowedPermissions []string, args *structs.JobRegisterRequest, reply *structs.JobRegisterResponse) error {\n\tif ok, err := registrationsAreAllowed(aclObj, j.srv.State()); !ok || err != nil {\n\t\tj.logger.Warn(\"job registration is currently disabled for non-management ACL\")\n\t\treturn structs.ErrJobRegistrationDisabled\n\t}\n\n\t// Validate the arguments\n\tif args.Job == nil {\n\t\treturn fmt.Errorf(\"missing job for registration\")\n\t}\n\n\t// defensive check; http layer and RPC requester should ensure namespaces are set consistently\n\tif args.RequestNamespace() != args.Job.Namespace {\n\t\treturn fmt.Errorf(\"mismatched request namespace in request: %q, %q\", args.RequestNamespace(), args.Job.Namespace)\n\t}\n\n\t// Run admission controllers\n\tjob, warnings, err := j.admissionControllers(args.Job)\n\tif err != nil {\n\t\treturn err\n\t}\n\targs.Job = job\n\n\t// Run the submission controller\n\twarnings = append(warnings, j.submissionController(args))\n\n\t// Attach the user token's accessor ID so that deploymentwatcher can","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint.go#L105-L141","documentation":"Nomad's job registration endpoint (nomad/job_endpoint.go:123) requires the request to carry a Job object. When JobRegister RPC arrives with args.Job == nil, the server rejects it because there is nothing to register or validate.","triggerScenarios":"Calling the Job.Register RPC (Register or Revert paths via doRegister) with a JobRegisterRequest whose Job field is nil — e.g. a hand-built RPC request or a malformed API payload that sets namespace/other fields but omits the job spec.","commonSituations":"Custom tooling or HTTP clients posting to /v1/jobs with an empty/invalid JSON body that deserializes to a nil Job; SDK wrappers that forward a nil job after failed parsing; older clients sending legacy payload shapes.","solutions":["Populate the Job field of the JobRegisterRequest with a complete *structs.Job before sending (set ID, Name, Namespace, TaskGroups, etc.).","If using the HTTP API, POST a valid HCL/JSON job body to /v1/jobs instead of an empty or partial body.","Check client-side deserialization: ensure the JSON key ('Job') matches and case-sensitive unmarshaling is not silently dropping it.","Validate the job locally (nomad job validate) before registering to catch malformed specs early."],"exampleFix":"// before\nreq := &structs.JobRegisterRequest{WriteRequest: w}\nsrv.RPC(\"Job.Register\", req, &resp)\n\n// after\nreq := &structs.JobRegisterRequest{Job: job, WriteRequest: w}\nsrv.RPC(\"Job.Register\", req, &resp)","handlingStrategy":"validation","validationCode":"if job == nil || job.ID == \"\" || len(job.TaskGroups) == 0 {\n\treturn fmt.Errorf(\"job spec must be non-nil with ID and TaskGroups before registration\")\n}","typeGuard":"func isRegisterableJob(j *api.Job) bool {\n\treturn j != nil && j.ID != nil && *j.ID != \"\" && len(j.TaskGroups) > 0\n}","tryCatchPattern":"_, _, err := client.Jobs().Register(job, nil)\nif err != nil && strings.Contains(err.Error(), \"missing job for registration\") {\n\treturn fmt.Errorf(\"request payload did not carry a job object: %w\", err)\n}","preventionTips":["Always construct/parse the job spec before building the register request.","Run `nomad job validate` (API or CLI) before registering.","Log the serialized request body when building RPCs manually.","Use the official API client rather than hand-rolled RPC structs."],"tags":["nomad","job-registration","validation","api"],"backgroundTag":"missing-required-payload","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"}