{"record":{"id":"be269ad150db52b5","repo":"hashicorp/nomad","slug":"missing-deployment-id","errorCode":null,"errorMessage":"missing deployment ID","messagePattern":"missing deployment ID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/deployment_endpoint.go","lineNumber":63,"sourceCode":"\tdefer metrics.MeasureSince([]string{\"nomad\", \"deployment\", \"get_deployment\"}, time.Now())\n\n\t// Check namespace read-job permissions\n\tallowNsOp := acl.NamespaceValidator(acl.NamespaceCapabilityReadJob)\n\taclObj, err := d.srv.ResolveACL(args)\n\tif err != nil {\n\t\treturn err\n\t} else if !allowNsOp(aclObj, args.RequestNamespace()) {\n\t\treturn structs.ErrPermissionDenied\n\t}\n\n\t// Setup the blocking query\n\topts := blockingOptions{\n\t\tqueryOpts: &args.QueryOptions,\n\t\tqueryMeta: &reply.QueryMeta,\n\t\trun: func(ws memdb.WatchSet, state *state.StateStore) error {\n\t\t\t// Verify the arguments\n\t\t\tif args.DeploymentID == \"\" {\n\t\t\t\treturn fmt.Errorf(\"missing deployment ID\")\n\t\t\t}\n\n\t\t\t// Look for the deployment\n\t\t\tout, err := state.DeploymentByID(ws, args.DeploymentID)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Re-check namespace in case it differs from request.\n\t\t\tif out != nil && !allowNsOp(aclObj, out.Namespace) {\n\t\t\t\t// hide this deployment, caller is not authorized to view it\n\t\t\t\tout = nil\n\t\t\t}\n\n\t\t\t// Setup the output\n\t\t\treply.Deployment = out\n\t\t\tif out != nil {\n\t\t\t\treply.Index = out.ModifyIndex","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/deployment_endpoint.go#L45-L81","documentation":"Nomad's DeploymentStatus (GetDeployment) RPC performs a blocking query for one deployment by ID. The ID check runs inside the blocking-query run function, so an empty args.DeploymentID causes the query to fail immediately with this validation error instead of returning a nil deployment. It means the client sent a read for a deployment without specifying which one.","triggerScenarios":"Calling GET /v1/deployment/<id> or nomad deployment status with an empty/blank deployment ID; SDK calls leaving DeploymentID unset; jobs that never created a deployment whose IDs were sourced from empty template output.","commonSituations":"CI pipelines parsing the deployment ID from nomad job deploy status output that failed earlier; scripts where DEPLOY_ID env var is unset; watching a deployment that was autoredacted/never started.","solutions":["Pass a concrete deployment ID: nomad deployment status <deployment-id>","Obtain the deployment ID from nomad job status <job> or GET /v1/job/<job>/deployments","Guard scripts: [ -n \"$DEPLOY_ID\" ] || exit 1 before calling","List all deployments (GET /v1/deployments) to locate the correct ID"],"exampleFix":"// before\nnomad deployment status \"$DEPLOY_ID\"   // var empty -> missing deployment ID\n\n// after\nDEPLOY_ID=$(nomad job inspect web | jq -r '.DeploymentID // empty')\n[ -n \"$DEPLOY_ID\" ] && nomad deployment status \"$DEPLOY_ID\"","handlingStrategy":"validation","validationCode":"if deploymentID == \"\" {\n    deps, _ := client.Jobs().Deployments(jobID, nil)\n    if len(deps) == 0 { return fmt.Errorf(\"job %s has no deployments\", jobID) }\n    deploymentID = deps[0].ID\n}","typeGuard":"func validDeploymentID(id string) bool {\n    return uuid.Parse(id) == nil || id != \"\"\n}","tryCatchPattern":"dep, _, err := client.Deployments().Get(id)\nif err != nil {\n    if strings.Contains(err.Error(), \"missing deployment ID\") {\n        return nil, fmt.Errorf(\"deployment ID empty; derive it from the job\")\n    }\n    return nil, err\n}","preventionTips":["Derive deployment IDs from the job's /deployments endpoint at runtime","Use `set -u` / strict-mode in scripts embedding $DEPLOY_ID","Reject blank IDs in CI before calling Nomad APIs","Store deployment IDs immediately after job submission"],"tags":["validation","deployment","nomad","missing-parameter"],"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"}