dgraph-io/dgraph · error

invalid task ID: %s

Error message

invalid task ID: %s

What it means

This error wraps a strconv.ParseUint failure when the GraphQL admin API tries to convert the task `id` input field into a uint64. Dgraph expects the task ID to be a numeric string (decimal or base-prefixed like 0x…); any other value makes strconv.ParseUint fail and the resolver wraps that failure with `invalid task ID: <input>` before returning an EmptyResult.

Source

Thrown at graphql/admin/task.go:38

	"github.com/dgraph-io/dgraph/v25/worker"
)

type taskInput struct {
	Id string
}

func resolveTask(ctx context.Context, q schema.Query) *resolve.Resolved {
	// Get Task ID.
	input, err := getTaskInput(q)
	if err != nil {
		return resolve.EmptyResult(q, err)
	}
	if input.Id == "" {
		return resolve.EmptyResult(q, fmt.Errorf("task ID is missing"))
	}
	taskId, err := strconv.ParseUint(input.Id, 0, 64)
	if err != nil {
		err = errors.Wrapf(err, "invalid task ID: %s", input.Id)
		return resolve.EmptyResult(q, err)
	}

	// Get TaskMeta from network.
	req := &pb.TaskStatusRequest{TaskId: taskId}
	resp, err := worker.TaskStatusOverNetwork(context.Background(), req)
	if err != nil {
		return resolve.EmptyResult(q, err)
	}
	meta := worker.TaskMeta(resp.GetTaskMeta())
	return resolve.DataResult(
		q,
		map[string]interface{}{q.Name(): map[string]interface{}{
			"kind":        meta.Kind().String(),
			"status":      meta.Status().String(),
			"lastUpdated": meta.Timestamp().Format(time.RFC3339),
		}},
		nil,

View on GitHub (pinned to 759e242be6)

Solutions

  1. Pass the numeric task ID exactly as returned by the task-creating mutation (e.g. "42"), not a name or prefixed string
  2. Trim whitespace and strip any label/prefix before sending the ID
  3. Verify the ID fits in an unsigned 64-bit integer (0 to 18446744073709551615)
  4. If IDs come from an external system, map them to Dgraph task IDs instead of passing them through

Example fix

// before
{ getTask(input: {id: "task:42"}) { response } }
// after
{ getTask(input: {id: "42"}) { response } }
Defensive patterns

Strategy: validation

Validate before calling

function isValidTaskID(id) {
  return typeof id === 'string' && /^\d+$/.test(id.trim()) && Number(id) <= 18446744073709551615n;
}
if (!isValidTaskID(input.id)) throw new Error('task ID must be a decimal string fitting uint64');

Type guard

const isNumericString = (v) => typeof v === 'string' && v.trim() !== '' && !isNaN(Number(v));

Prevention

When it happens

Trigger: Calling the admin API getTask/queryTask resolver `resolveTask` with `input.Id` set to a non-numeric string (e.g. "abc", "12ab", an empty-after-trim value, a UUID, or a number exceeding uint64 range like "99999999999999999999999"). Note ParseUint with base 0 also rejects values with signs or invalid prefixes.

Common situations: Pasting a human-readable job name instead of the numeric task ID returned by a prior mutation; copying an ID with whitespace or a trailing newline; scripting the admin endpoint and formatting the ID as "task:42"; overflowing 64-bit values when IDs come from another system.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/164876ccb4006156. Report an issue: GitHub.