{"record":{"id":"f50258623b7148dc","repo":"hashicorp/nomad","slug":"job-s-does-not-have-allocation-s","errorCode":null,"errorMessage":"job %s does not have allocation %s","messagePattern":"job (.+?) does not have allocation (.+?)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"client/alloc_endpoint.go","lineNumber":300,"sourceCode":"\n\t\ta.c.logger.Info(\"task exec session starting\", logArgs...)\n\t}\n\n\t// Check alloc-exec permission.\n\tif err != nil {\n\t\treturn new(int64(400)), err\n\t} else if !aclObj.AllowNsOp(alloc.Namespace, acl.NamespaceCapabilityAllocExec) {\n\t\treturn nil, nstructs.ErrPermissionDenied\n\t}\n\n\t// Validate the arguments\n\tif req.Task == \"\" {\n\t\treturn new(int64(400)), taskNotPresentErr\n\t}\n\n\tif req.JobID != \"\" && req.JobID != alloc.JobID {\n\t\treturn new(int64(http.StatusBadRequest)),\n\t\t\tfmt.Errorf(\"job %s does not have allocation %s\", req.JobID, req.AllocID)\n\t}\n\n\t// If an action is present, go find the command and args\n\tif req.Action != \"\" {\n\t\ttask := alloc.LookupTask(req.Task)\n\t\tif task == nil {\n\t\t\treturn new(int64(http.StatusBadRequest)),\n\t\t\t\tfmt.Errorf(\"task %s not found in allocation %s\", req.Task, alloc.ID)\n\t\t}\n\t\tjobAction := task.GetAction(req.Action)\n\t\tif jobAction == nil {\n\t\t\treturn new(int64(http.StatusBadRequest)),\n\t\t\t\tfmt.Errorf(\"action %s not found in task %s\", req.Action, req.Task)\n\t\t}\n\n\t\t// append both Command and Args\n\t\treq.Cmd = append([]string{jobAction.Command}, jobAction.Args...)\n\t}","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/alloc_endpoint.go#L282-L318","documentation":"Returned by execImpl when the exec request carries a JobID that differs from the allocation's actual JobID. This is a client-side mismatch guard so exec cannot be issued against an allocation belonging to a different job.","triggerScenarios":"Thrown at client/alloc_endpoint.go:300 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Compare req.JobID with the target allocation's JobID using nomad alloc status","Omit the job_id field or pass the allocation's actual job ID","Re-run the exec command against the correct allocation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}