dgraph-io/dgraph · error
Invalid argument: %s
Error message
Invalid argument: %s
What it means
Each argument on a query node must be one of the recognized keywords (first, offset, after, orderasc, orderby, filter, facets, cascade, etc.). treeCopy iterates gchild.Args and calls isValidArg; an unknown key means the query is malformed or uses syntax from another engine, so parsing is aborted with the offending argument name.
Source
Thrown at query/query.go:596
args.Cascade.Fields = gchild.Cascade
}
// Remove pagination arguments from the query if @cascade is mentioned since
// pagination will be applied post processing the data.
if len(args.Cascade.Fields) > 0 {
args.addCascadePaginationArguments(gchild)
}
if gchild.IsCount {
if len(gchild.Children) != 0 {
return errors.New("Node with count cannot have child attributes")
}
args.DoCount = true
}
for argk := range gchild.Args {
if !isValidArg(argk) {
return errors.Errorf("Invalid argument: %s", argk)
}
}
if err := args.fill(gchild); err != nil {
return err
}
if len(args.Order) != 0 && len(args.FacetsOrder) != 0 {
return errors.Errorf("Cannot specify order at both args and facets")
}
dst := &SubGraph{
Attr: gchild.Attr,
Params: args,
}
if gchild.MathExp != nil {
mathExp := &mathTree{}
if err := mathCopy(mathExp, gchild.MathExp); err != nil {
return errView on GitHub (pinned to 759e242be6)
Solutions
- Fix the argument spelling to a supported one (first, offset, after, orderasc, orderdesc, orderby, filter, facets, groupby, recurse, cascade, depth, etc.)
- Replace unsupported options with Dgraph equivalents: pagination is (first, offset) and (after, first)
- Check the predicate is not being passed where an argument belongs; move values into func(...) or @filter instead
Example fix
// before
{
me(func: type(Person), limit: 5) { uid }
}
// after
{
me(func: type(Person), first: 5) { uid }
} Defensive patterns
Strategy: validation
Validate before calling
const VALID_ARGS = new Set(['first','offset','after','orderasc','orderdesc','orderby','filter','facets','groupby','cascade','recurse','depth','loop','numpaths','minweight','maxweight','numhops','maxfrontiersize','from','to','func','expand']);
for (const [k] of node.args) {
if (!VALID_ARGS.has(k)) throw new Error(`Unknown Dgraph argument: ${k}`);
} Type guard
const isValidDgraphArg = (k) => VALID_ARGS.has(k);
Try / catch
try {
await txn.query(q);
} catch (e) {
if (e.message.startsWith('Invalid argument:')) {
const bad = e.message.split('Invalid argument: ')[1];
console.error(`Remove or correct argument "${bad}"`);
}
throw e;
} Prevention
- Keep an allowlist of Dgraph query arguments in your query builder
- Map SQL/GraphQL options (limit/skip) to first/offset before emitting
- Re-check args after Dgraph upgrades, as supported args change
When it happens
Trigger: Typo like `orderasc:` misspelled as `orderAsc` or `oderby`; passing an arbitrary option such as `limit: 5` (not a Dgraph arg); query builders injecting custom parameters into the query string.
Common situations: Hand-written queries with typos; porting GraphQL/SQL options (limit/skip) that Dgraph does not support by that name; old syntax removed in a Dgraph upgrade.
Related errors
- expand() not allowed inside shortest
- Node with count cannot have child attributes
- Node with %q cant have child attr
- NQuad failed sanity check. Subject: %q, Predicate: %q, Objec
- empty variable name in function call
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/ad1f536514a1215d.
Report an issue: GitHub.