dgraph-io/dgraph · error
unknown value kind: %d, for value: %s
Error message
unknown value kind: %d, for value: %s
What it means
This is the fallback case of the GraphQL AST value-to-Go converter: the value node's Kind was not any recognized kind (Boolean, String, Block, Enum, Null). It indicates an unexpected/unhandled AST value kind reached the conversion function.
Source
Thrown at graphql/schema/wrappers.go:2992
vars[value.Raw] = true
return value.String(), nil
case ast.IntValue:
return strconv.ParseInt(value.Raw, 10, 64)
case ast.FloatValue:
return strconv.ParseFloat(value.Raw, 64)
case ast.BooleanValue:
return strconv.ParseBool(value.Raw)
case ast.StringValue:
return value.Raw, nil
case ast.BlockValue, ast.EnumValue:
if strictJSON {
return nil, fmt.Errorf("found unexpected value: %s", value.String())
}
return value.Raw, nil
case ast.NullValue:
return nil, nil
default:
return nil, fmt.Errorf("unknown value kind: %d, for value: %s", value.Kind, value.String())
}
}
// Given a template for a body with variables defined, this function parses the body
// and converts it into a JSON representation and returns that. It also returns a list of the
// variable names that are required by this template.
// for e.g.
// { author: $id, post: { id: $postID }}
// would return
// { "author" : "$id", "post": { "id": "$postID" }} and { "id": true, "postID": true}
// If the final result is not a valid JSON, then an error is returned.
//
// In strictJSON mode block strings and enums are invalid and throw an error.
// strictJSON should be false when the body template is being used for custom graphql arg parsing,
// otherwise it should be true.
func parseBodyTemplate(body string, strictJSON bool) (interface{}, map[string]bool, error) {
if strings.TrimSpace(body) == "" {
return nil, nil, nilView on GitHub (pinned to 759e242be6)
Solutions
- Inspect the reported value kind and route numeric/variable values to the appropriate converter
- Upgrade/patch the library so the converter handles all value kinds
- Pre-process the AST to inline variables before conversion
Defensive patterns
Strategy: try-catch
Try / catch
v, err := convertValue(node)
if err != nil {
if strings.Contains(err.Error(), "unknown value kind") {
log.Printf("unhandled AST kind %v", node.Kind)
return handleUnknownKind(node) // custom branch
}
return err
} Prevention
- Keep the converter updated for all ast.Kind values
- Inline/simplify variable and numeric nodes before conversion
- Report unhandled kinds upstream as library bugs
When it happens
Trigger: A value node with an unhandled ast.Kind (e.g. IntValue/FloatValue or Variable if not handled elsewhere) is passed to this conversion function, hitting the default branch.
Common situations: Library bugs or custom AST construction, passing numeric or variable nodes into a converter that only expects string-like/null values, or version mismatch where new AST kinds aren't handled.
Related errors
- found unexpected value: %s
- 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/ba359fd0d44f1697.
Report an issue: GitHub.