dgraph-io/dgraph · error
ID argument (%s) was not able to be parsed
Error message
ID argument (%s) was not able to be parsed
What it means
asUID received a value that is not nil but could not be converted to a uint64 UID: either the value was not a string (ok==false) or strconv.ParseUint failed on the string. The error includes the offending value so developers can see what was actually passed. Called from checkUIDExistsQuery and addDelete during delete mutations.
Source
Thrown at graphql/resolve/mutation_rewriter.go:1177
func (drw *deleteRewriter) RewriteQueries(
ctx context.Context,
m schema.Mutation) ([]*dql.GraphQuery, []string, error) {
drw.VarGen = NewVariableGenerator()
return []*dql.GraphQuery{}, []string{}, nil
}
func asUID(val interface{}) (uint64, error) {
if val == nil {
return 0, errors.Errorf("ID value was null")
}
id, ok := val.(string)
uid, err := strconv.ParseUint(id, 0, 64)
if !ok || err != nil {
return 0, errors.Errorf("ID argument (%s) was not able to be parsed", id)
}
return uid, nil
}
func addAuthSelector(t schema.Type) *schema.RuleNode {
auth := t.AuthRules()
if auth == nil || auth.Rules == nil {
return nil
}
return auth.Rules.Add
}
func updateAuthSelector(t schema.Type) *schema.RuleNode {
auth := t.AuthRules()
if auth == nil || auth.Rules == nil {
return nilView on GitHub (pinned to 759e242be6)
Solutions
- Pass the internal hex UID string (e.g. "0x1234") obtained from a prior query/add response
- If using @id/XID values, query the node first to resolve its UID, or use the proper XID-based filter path
- Ensure the id argument is a string, not a JSON number
- Trim whitespace and validate the UID format (strconv.ParseUint base 0) before sending
Example fix
// before deletePost(id: "my-xid-value") // after deletePost(id: "0x2") // hex UID from query result
Defensive patterns
Strategy: type-guard
Validate before calling
function isParsableUID(v) {
return typeof v === 'string' && !isNaN(Number.parseInt(v, v.startsWith('0x') ? 16 : 10));
} Type guard
function isUidString(v) { return typeof v === 'string' && /^0x[0-9a-fA-F]+$/.test(v.trim()); } Try / catch
try {
await deleteMutation({ id });
} catch (err) {
if (err.message.startsWith('ID argument (')) {
// resolve the real hex UID via query, then retry
}
} Prevention
- Always pass hex UIDs ("0x...") from prior query results
- Resolve @id/XID values to UIDs before delete mutations
- Keep id arguments as strings, not JSON numbers
- Trim/normalize ID strings before sending
When it happens
Trigger: Passing an id argument with a non-numeric string (e.g. 'abc', an XID instead of a hex UID, or '0x' prefix missing), or a non-string JSON type (number) into asUID where only strings are supported.
Common situations: Using an external/@id string value where the internal hex UID (0x1) is expected; passing numeric IDs (1234) serialized as JSON numbers; typos or whitespace in the UID string.
Related errors
- ID value was null
- Cycle detected: %s
- Missing fragment: %s
- PersistedQueryNotFound
- provided sha does not match query
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/6f0c68b3dc9531f9.
Report an issue: GitHub.