dgraph-io/dgraph · error

can't convert input.tablet to string

Error message

can't convert input.tablet to string

What it means

After the namespace field, getMoveTabletInput asserts input.tablet to a string; if the value is absent or not a string (e.g. a number, bool, or object), this error is returned via inputArgError. The tablet parameter identifies the tablet to move and the resolver requires it as the string form of the tablet ID (or tablet address).

Source

Thrown at graphql/admin/moveTablet.go:69

		return nil, inputArgError(errors.Errorf("can't convert input to map"))
	}

	inputRef := &moveTabletInput{}
	// namespace is an optional parameter
	if _, ok = inputArg["namespace"]; !ok {
		inputRef.Namespace = x.RootNamespace
	} else {
		ns, err := parseAsUint64(inputArg["namespace"])
		if err != nil {
			return nil, inputArgError(schema.GQLWrapf(err,
				"can't convert input.namespace to uint64"))
		}
		inputRef.Namespace = ns
	}

	inputRef.Tablet, ok = inputArg["tablet"].(string)
	if !ok {
		return nil, inputArgError(errors.Errorf("can't convert input.tablet to string"))
	}

	gId, err := parseAsUint32(inputArg["groupId"])
	if err != nil {
		return nil, inputArgError(schema.GQLWrapf(err, "can't convert input.groupId to uint32"))
	}
	inputRef.GroupId = gId

	return inputRef, nil
}

View on GitHub (pinned to 759e242be6)

Solutions

  1. Pass tablet as a JSON string: {"tablet": "5"}, quoting any numeric ID.
  2. Confirm the field is spelled exactly 'tablet' and present in the input object.
  3. If the value comes from a variable or template, coerce it with String(id) / fmt.Sprintf("%d", id) before sending.
  4. Cross-check the tablet ID against /state or theRaft listing so the string matches an existing tablet.
  5. Update the client schema/types if it models tablet as a number.

Example fix

// before
{"input": {"tablet": 5, "groupId": 1}}
// after
{"input": {"tablet": "5", "groupId": 1}}
Defensive patterns

Strategy: validation

Validate before calling

function assertTablet(v) {
  const t = v && v.input && v.input.tablet;
  if (typeof t !== 'string' || t === '') throw new Error('input.tablet must be a non-empty string');
  return t;
}

Type guard

function isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; }

Try / catch

try {
  await gql(moveTabletMutation, { input: { ...input, tablet: String(input.tablet) } });
} catch (e) {
  if (String(e.message).includes("can't convert input.tablet to string")) {
    // coerce tablet to string (or the field is missing) and retry
  }
}

Prevention

When it happens

Trigger: Calling moveTablet without the 'tablet' field in input, or passing it as a numeric JSON value like {"tablet": 5} instead of {"tablet": "5"}, or passing an object/null.

Common situations: Clients that auto-convert tablet IDs to numbers, code generators serializing IDs as ints, or developers copying moveTablet calls from Raft output where the tablet ID is printed as a number. Also happens when the field name is misspelled ('tabletId') so 'tablet' is missing entirely.

Related errors


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