{"record":{"id":"68ab7b6e25cb3884","repo":"hashicorp/nomad","slug":"missing-allocation-id-68ab7b","errorCode":null,"errorMessage":"Missing allocation ID","messagePattern":"Missing allocation ID","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/errors.go","lineNumber":65,"sourceCode":"\terrDeploymentTerminalNoRun       = \"can't run terminal deployment\"\n\terrDeploymentTerminalNoSetHealth = \"can't set health of allocations for a terminal deployment\"\n\terrDeploymentRunningNoUnblock    = \"can't unblock running deployment\"\n)\n\nvar (\n\tErrNoLeader                   = errors.New(errNoLeader)\n\tErrNotReadyForConsistentReads = errors.New(errNotReadyForConsistentReads)\n\tErrNoRegionPath               = errors.New(errNoRegionPath)\n\tErrTokenNotFound              = errors.New(errTokenNotFound)\n\tErrTokenExpired               = errors.New(errTokenExpired)\n\tErrTokenInvalid               = errors.New(errTokenInvalid)\n\tErrPermissionDenied           = errors.New(errPermissionDenied)\n\tErrJobRegistrationDisabled    = errors.New(errJobRegistrationDisabled)\n\tErrNoNodeConn                 = errors.New(errNoNodeConn)\n\tErrUnknownMethod              = errors.New(errUnknownMethod)\n\tErrUnknownNomadVersion        = errors.New(errUnknownNomadVersion)\n\tErrNodeLacksRpc               = errors.New(errNodeLacksRpc)\n\tErrMissingAllocID             = errors.New(errMissingAllocID)\n\tErrIncompatibleFiltering      = errors.New(errIncompatibleFiltering)\n\tErrMalformedChooseParameter   = errors.New(errMalformedChooseParameter)\n\n\t// ErrResultPaginatorCreation is returned by list RPC handlers when the\n\t// result paginator cannot be built, for example when the server cannot\n\t// evaluate a requested filter expression. api.ResultPaginatorErrorContent\n\t// duplicates its message so the CLI can match it without importing structs.\n\t// Keep the two in sync.\n\tErrResultPaginatorCreation = errors.New(errResultPaginatorCreation)\n\n\tErrUnknownNode = errors.New(ErrUnknownNodePrefix)\n\n\tErrDeploymentTerminalNoCancel    = errors.New(errDeploymentTerminalNoCancel)\n\tErrDeploymentTerminalNoFail      = errors.New(errDeploymentTerminalNoFail)\n\tErrDeploymentTerminalNoPause     = errors.New(errDeploymentTerminalNoPause)\n\tErrDeploymentTerminalNoPromote   = errors.New(errDeploymentTerminalNoPromote)\n\tErrDeploymentTerminalNoResume    = errors.New(errDeploymentTerminalNoResume)\n\tErrDeploymentTerminalNoUnblock   = errors.New(errDeploymentTerminalNoUnblock)","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/errors.go#L47-L83","documentation":"ErrMissingAllocID is a request-validation error returned by client allocation endpoints (Stats, Restart, logs, getAlloc) when the request's AllocID field is empty. The handlers reject the call up front rather than attempting a lookup with a blank ID.","triggerScenarios":"Sending ClientAllocations.Stats, ClientAllocations.Restart, or fs/log RPCs with req.AllocID == \"\"; constructing the request struct without copying the allocation ID from the job/alloc object; tests that deliberately omit AllocID.","commonSituations":"Automation that reads the alloc ID from an unset variable or empty API response; copying request structs and dropping the ID field; CLI/API callers passing a placeholder before an allocation was actually placed.","solutions":["Populate req.AllocID with a valid allocation ID before the call.","Fetch the allocation first (e.g. via Allocations.List or job status) and use its ID.","Add client-side validation that errors early when the ID is empty.","Verify you are reading the correct field (Alloc.ID, not Job ID or Node ID)."],"exampleFix":"// before\nreq := &nstructs.AllocSpecificRequest{}\n// after\nreq := &nstructs.AllocSpecificRequest{AllocID: alloc.ID}","handlingStrategy":"validation","validationCode":"if allocID == \"\" { return errors.New(\"allocation ID is required\") }","typeGuard":"func hasAllocID(req *structs.AllocSpecificRequest) bool { return req != nil && req.AllocID != \"\" }","tryCatchPattern":"if err := msgpackrpc.CallWithCodec(codec, \"ClientAllocations.Stats\", req, &resp); err != nil {\n    if strings.Contains(err.Error(), structs.ErrMissingAllocID.Error()) {\n        return fmt.Errorf(\"request rejected: alloc ID missing in %T\", req)\n    }\n    return err\n}","preventionTips":["Construct RPC requests via helpers that require the alloc ID parameter","Validate request structs in unit tests before hitting the API","Distinguish alloc IDs from job/node IDs in your automation","Fail fast client-side when upstream data sources return an empty ID"],"tags":["rpc","nomad","request-validation"],"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"}