{"record":{"id":"4f67101a66abae52","repo":"dgraph-io/dgraph","slug":"invalid-task-id-x","errorCode":null,"errorMessage":"invalid task ID: %#x","messagePattern":"invalid task ID: %#x","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/queue.go","lineNumber":35,"sourceCode":"\n\t\"github.com/golang/glog\"\n\t\"github.com/pkg/errors\"\n\n\t\"github.com/dgraph-io/dgraph/v25/conn\"\n\t\"github.com/dgraph-io/dgraph/v25/protos/pb\"\n\t\"github.com/dgraph-io/dgraph/v25/raftwal\"\n\t\"github.com/dgraph-io/dgraph/v25/x\"\n\t\"github.com/dgraph-io/ristretto/v2/z\"\n)\n\n// TaskStatusOverNetwork fetches the status of a task over the network. Alphas only know about the\n// tasks created by them, but this function would fetch the task from the correct Alpha.\nfunc TaskStatusOverNetwork(ctx context.Context, req *pb.TaskStatusRequest,\n) (*pb.TaskStatusResponse, error) {\n\t// Extract Raft ID from Task ID.\n\ttaskId := req.GetTaskId()\n\tif taskId == 0 {\n\t\treturn nil, fmt.Errorf(\"invalid task ID: %#x\", taskId)\n\t}\n\traftId := taskId >> 32\n\n\t// Skip the network call if the required Alpha is me.\n\tmyRaftId := State.WALstore.Uint(raftwal.RaftId)\n\tif raftId == myRaftId {\n\t\tworker := (*grpcWorker)(nil)\n\t\treturn worker.TaskStatus(ctx, req)\n\t}\n\n\t// Find the Alpha with the required Raft ID.\n\tvar addr string\n\tfor _, group := range groups().state.GetGroups() {\n\t\tfor _, member := range group.GetMembers() {\n\t\t\tif member.GetId() == raftId {\n\t\t\t\taddr = member.GetAddr()\n\t\t\t}\n\t\t}","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/queue.go#L17-L53","documentation":"TaskStatusOverNetwork validates the task ID from a TaskStatusRequest before decoding it; an ID of 0 cannot encode a Raft ID in its upper 32 bits (taskId >> 32), so it is rejected with 'invalid task ID: %#x'. This is an input-validation error indicating the client passed an uninitialized or malformed task ID.","triggerScenarios":"Calling TaskStatusOverNetwork (e.g. via the resolveTask path, often while retrying a mutation that returned a task ID) with req.GetTaskId() == 0 — typically when the original mutation response was never populated with a task ID.","commonSituations":"A client stores the task ID before the mutation RPC returns and the field defaults to zero; retry logic constructs a TaskStatusRequest from an empty protobuf; code that ignores the error from Enqueue and uses the 0 ID returned alongside it.","solutions":["Check the error returned by Enqueue/initial mutation before using the returned task ID (error and ID can both be zero)","Only build a TaskStatusRequest with a nonzero task ID obtained from a successful Enqueue","If the original task ID was lost, re-run the backup/export operation to get a new one"],"exampleFix":"// before\nresp, _ := pb.TaskStatusOverNetwork(ctx, &pb.TaskStatusRequest{TaskId: id})\n// after\nif id == 0 {\n    return fmt.Errorf(\"no task ID recorded from mutation\")\n}\nresp, err := pb.TaskStatusOverNetwork(ctx, &pb.TaskStatusRequest{TaskId: id})\nif err != nil { return err }","handlingStrategy":"validation","validationCode":"func validTaskID(id uint64) bool { return id != 0 }\n// call: if !validTaskID(req.GetTaskId()) { return error }","typeGuard":"func hasTaskID(req *pb.TaskStatusRequest) bool {\n    return req != nil && req.GetTaskId() != 0\n}","tryCatchPattern":"meta, err := worker.TaskStatusOverNetwork(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"invalid task ID\") {\n    return fmt.Errorf(\"no task ID recorded; capture the ID returned by a successful enqueue\")\n}","preventionTips":["Never ignore the error return of Enqueue — the ID is only valid on success","Persist the task ID immediately after receiving it","Initialize protobuf fields explicitly rather than relying on zero values"],"tags":["validation","task-id","dgraph"],"backgroundTag":"invalid-task-id","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}