{"record":{"id":"d701544e23877ed8","repo":"hashicorp/nomad","slug":"alloc-v-does-not-have-a-job","errorCode":null,"errorMessage":"alloc %v does not have a job","messagePattern":"alloc (.+?) does not have a job","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/consul_hook.go","lineNumber":90,"sourceCode":"\n// statically assert the hook implements the expected interfaces\nvar (\n\t_ interfaces.RunnerPrerunHook  = (*consulHook)(nil)\n\t_ interfaces.RunnerPostrunHook = (*consulHook)(nil)\n\t_ interfaces.RunnerDestroyHook = (*consulHook)(nil)\n\t_ interfaces.ShutdownHook      = (*consulHook)(nil)\n)\n\nfunc (*consulHook) Name() string {\n\treturn \"consul\"\n}\n\nfunc (h *consulHook) Prerun(allocEnv *taskenv.TaskEnv) error {\n\tjob := h.alloc.Job\n\n\tif job == nil {\n\t\t// this is always a programming error\n\t\terr := fmt.Errorf(\"alloc %v does not have a job\", h.alloc.Name)\n\t\th.logger.Error(err.Error())\n\t\treturn err\n\t}\n\n\t// tokens are a map of Consul cluster to identity name to Consul ACL token.\n\ttokens, err := h.resourcesBackend.loadAllocTokens()\n\tif err != nil {\n\t\th.logger.Error(\"error reading stored ACL tokens\", \"error\", err)\n\t}\n\n\ttg := job.LookupTaskGroup(h.alloc.TaskGroup)\n\tif tg == nil { // this is always a programming error\n\t\treturn fmt.Errorf(\"alloc %v does not have a valid task group\", h.alloc.Name)\n\t}\n\n\tvar mErr *multierror.Error\n\tif err := h.prepareConsulTokensForServices(tg.Services, tg, tokens, allocEnv); err != nil {\n\t\tmErr = multierror.Append(mErr, err)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/consul_hook.go#L72-L108","documentation":"consulHook.Prerun guard: h.alloc.Job is nil when the allocation's prerun hook executes. The code marks this as always a programming/state corruption error - every persisted allocation should carry its job - so it logs at Error level and aborts startup.","triggerScenarios":"Thrown at client/allocrunner/consul_hook.go:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report as a bug; this indicates alloc state corruption","Check whether the alloc was restored from a truncated/partial state DB","Delete the corrupt alloc directory / restart the client to force re-sync from servers"],"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"}