{"record":{"id":"739260c59506ce1a","repo":"dgraph-io/dgraph","slug":"task-id-is-missing","errorCode":null,"errorMessage":"task ID is missing","messagePattern":"task ID is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/admin/task.go","lineNumber":34,"sourceCode":"\n\t\"github.com/dgraph-io/dgraph/v25/graphql/resolve\"\n\t\"github.com/dgraph-io/dgraph/v25/graphql/schema\"\n\t\"github.com/dgraph-io/dgraph/v25/protos/pb\"\n\t\"github.com/dgraph-io/dgraph/v25/worker\"\n)\n\ntype taskInput struct {\n\tId string\n}\n\nfunc resolveTask(ctx context.Context, q schema.Query) *resolve.Resolved {\n\t// Get Task ID.\n\tinput, err := getTaskInput(q)\n\tif err != nil {\n\t\treturn resolve.EmptyResult(q, err)\n\t}\n\tif input.Id == \"\" {\n\t\treturn resolve.EmptyResult(q, fmt.Errorf(\"task ID is missing\"))\n\t}\n\ttaskId, err := strconv.ParseUint(input.Id, 0, 64)\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \"invalid task ID: %s\", input.Id)\n\t\treturn resolve.EmptyResult(q, err)\n\t}\n\n\t// Get TaskMeta from network.\n\treq := &pb.TaskStatusRequest{TaskId: taskId}\n\tresp, err := worker.TaskStatusOverNetwork(context.Background(), req)\n\tif err != nil {\n\t\treturn resolve.EmptyResult(q, err)\n\t}\n\tmeta := worker.TaskMeta(resp.GetTaskMeta())\n\treturn resolve.DataResult(\n\t\tq,\n\t\tmap[string]interface{}{q.Name(): map[string]interface{}{\n\t\t\t\"kind\":        meta.Kind().String(),","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/admin/task.go#L16-L52","documentation":"resolveTask looks up a background task (e.g. a backup restore) by ID via the admin GraphQL API. After getTaskInput succeeds it still checks that input.Id is a non-empty string and returns 'task ID is missing' if it is empty. The error guards the downstream strconv.ParseUint call, which would otherwise produce a confusing parse error on \"\".","triggerScenarios":"Querying task with an empty id: { task(input: { id: \"\" }) { ... } }, omitting the id field in the input object, or a client template that interpolates an undefined/empty task ID.","commonSituations":"Automation that captures a task ID from a restore response into a variable that was never set, retry logic re-running a task query before the mutation response was parsed, or frontend state losing the id between requests.","solutions":["Supply a valid task ID: { task(input: { id: \"1\" }) { ... } }.","Capture the task ID from the restore/backup mutation response before querying task status.","Add client-side validation rejecting empty id values before issuing the query.","If the id is dynamic, log/assert it is non-empty; fix whatever failed to populate it.","Remember the ID must also parse as an unsigned integer — use the exact ID returned by the server."],"exampleFix":"// before\nquery { task(input: { id: \"\" }) { status } }\n// after\nquery { task(input: { id: \"42\" }) { status } }","handlingStrategy":"validation","validationCode":"function assertTaskId(id) {\n  if (typeof id !== 'string' || id.trim() === '') throw new Error('task ID is required and must be a non-empty numeric string');\n  if (!/^\\d+$/.test(id.trim())) throw new Error('task ID must parse as an unsigned integer');\n  return id.trim();\n}","typeGuard":"function isValidTaskId(v) { return typeof v === 'string' && /^\\d+$/.test(v); }","tryCatchPattern":"try {\n  const res = await gql(taskQuery, { input: { id: assertTaskId(taskId) } });\n} catch (e) {\n  if (String(e.message).includes('task ID is missing')) {\n    // re-fetch the task id from the original restore/backup response, then retry\n  }\n}","preventionTips":["Always capture the task ID from the restore/backup mutation response before polling","Fail fast in scripts when the captured ID is undefined/empty","Type the task id as a non-nullable string in client code","Log the task ID at mutation time for later debugging","Use the exact server-returned ID; it must parse as an unsigned integer"],"tags":["graphql","tasks","input-validation","admin-api"],"backgroundTag":"missing-required-argument","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}