dgraph-io/dgraph · error
can't convert input to map
Error message
can't convert input to map
What it means
getAssignInput extracts the 'input' argument of the assignDgraphMutation (assign UID) mutation and asserts it is a map. If the GraphQL-provided argument value is not a map[string]interface{}, the mutation fails with this wrapped inputArgError.
Source
Thrown at graphql/admin/assign.go:80
endId = json.Number(strconv.FormatUint(resp.GetEndId(), 10))
}
return resolve.DataResult(m,
map[string]interface{}{m.Name(): map[string]interface{}{
"response": map[string]interface{}{
"startId": startId,
"endId": endId,
"readOnly": readOnly,
},
}},
nil,
), true
}
func getAssignInput(m schema.Mutation) (*assignInput, error) {
inputArg, ok := m.ArgValue(schema.InputArgName).(map[string]interface{})
if !ok {
return nil, inputArgError(errors.Errorf("can't convert input to map"))
}
inputRef := &assignInput{}
inputRef.What, ok = inputArg["what"].(string)
if !ok {
return nil, inputArgError(errors.Errorf("can't convert input.what to string"))
}
num, err := parseAsUint64(inputArg["num"])
if err != nil {
return nil, inputArgError(schema.GQLWrapf(err, "can't convert input.num to uint64"))
}
inputRef.Num = num
return inputRef, nil
}
View on GitHub (pinned to 759e242be6)
Solutions
- Send input as a JSON object: {"what": "uids", "num": 100} — not an array or string.
- If using GraphQL variables, pass them as an object, not a JSON-encoded string.
- Check the resolver wrapping in inputArgError in the response to confirm which field was malformed.
Example fix
// before
{"query":"mutation { assignDgraphUids(input: \"bad\") { ... } }"}
// after
{"query":"mutation { assignDgraphUids(input: { what: uids, num: 100 }) { value } }"} Defensive patterns
Strategy: validation
Validate before calling
function validateAssignInput(input) {
if (typeof input !== 'object' || input === null || Array.isArray(input))
throw new Error("assignDgraphUids input must be an object like { what: 'uids', num: 100 }");
} Type guard
function isAssignInput(v) { return typeof v === 'object' && v !== null && !Array.isArray(v) && typeof v.what === 'string'; } Try / catch
try { await assign(input); } catch (e) { if (String(e).includes("can't convert input to map")) { throw new Error('Malformed assign payload: input must be an object'); } throw e; } Prevention
- Build mutation inputs as JSON objects, never JSON-encoded strings
- Use GraphQL typed variables instead of string interpolation
- Validate payloads with a schema validator before sending
When it happens
Trigger: Calling assignDgraphMutation with an 'input' argument that is not an object (e.g. a JSON array, string, or null) via the /mutation HTTP endpoint or a raw GraphQL mutation.
Common situations: Crafting the mutation payload by hand and passing input as a list or scalar; sending the raw JSON body directly to /mutation instead of using typed GraphQL variables; tooling serializing input incorrectly.
Related errors
- can't convert input.what to string
- can't convert input to map
- can't convert input to map
- not able to find set args in update mutation
- you must specify a 'destination' value
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/83a9b5a875c97146.
Report an issue: GitHub.