dgraph-io/dgraph · error
found unexpected value: %s
Error message
found unexpected value: %s
What it means
When converting GraphQL AST values to Go values, BlockValue (block strings) and EnumValue kinds are only accepted when strictJSON is false. This error fires when strictJSON mode is enabled and the parser encounters a block string or enum value where a JSON-compatible value is expected.
Source
Thrown at graphql/schema/wrappers.go:2986
return nil, err
}
l = append(l, elemVal)
}
return l, nil
case ast.Variable:
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.
//View on GitHub (pinned to 759e242be6)
Solutions
- Disable strictJSON if enum/block values are legitimate in your context
- Replace the enum literal with a string value in the template/body
- Replace block strings ("""...""") with regular quoted strings
- Convert enum values to their string representations before evaluation
Example fix
// before status: ACTIVE // enum value under strictJSON // after status: "ACTIVE"
Defensive patterns
Strategy: fallback
Validate before calling
switch value.Kind {
case ast.BooleanValue, ast.StringValue, ast.NullValue: // safe
case ast.BlockValue, ast.EnumValue: // not allowed under strictJSON
return errors.New("enum/block value not allowed in strict JSON mode")
} Try / catch
if err := convertValue(v); err != nil {
if strings.Contains(err.Error(), "found unexpected value") {
return convertNonStrict(v) // fallback path
}
return err
} Prevention
- Avoid enum literals and block strings in strict-JSON contexts
- Use string values instead of enum AST nodes in templates
- Confirm strictJSON setting matches the data you feed the converter
When it happens
Trigger: Evaluating a value node (e.g. a variable default or argument) in strictJSON mode where the AST contains an ast.BlockValue or ast.EnumValue node.
Common situations: Using enum literals or triple-quoted block strings in contexts the strict JSON conversion path processes, e.g. building request bodies from templates with enum defaults.
Related errors
- unknown value kind: %d, for 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/50fa9c582cdc8055.
Report an issue: GitHub.