dgraph-io/dgraph · error
while fetching types
Error message
while fetching types
What it means
When the query requests types (schema(type: X) or types in schema block), Dgraph fetches type definitions via worker.GetTypes over the network. Failures of that call surface as this wrapped error, meaning type metadata could not be retrieved from the cluster.
Source
Thrown at query/query.go:3072
for _, sg := range er.Subgraphs {
calculateMetrics(sg, metrics)
}
er.Metrics = metrics
namespace, err := x.ExtractNamespace(ctx)
if err != nil {
return er, errors.Wrapf(err, "While processing query")
}
schemaProcessingStart := time.Now()
if req.DqlQuery.Schema != nil {
preds := x.NamespaceAttrList(namespace, req.DqlQuery.Schema.Predicates)
req.DqlQuery.Schema.Predicates = preds
if er.SchemaNode, err = worker.GetSchemaOverNetwork(ctx, req.DqlQuery.Schema); err != nil {
return er, errors.Wrapf(err, "while fetching schema")
}
typeNames := x.NamespaceAttrList(namespace, req.DqlQuery.Schema.Types)
req.DqlQuery.Schema.Types = typeNames
if er.Types, err = worker.GetTypes(ctx, req.DqlQuery.Schema); err != nil {
return er, errors.Wrapf(err, "while fetching types")
}
}
if !x.IsRootNsOperation(ctx) {
// Filter the schema nodes for the given namespace.
er.SchemaNode = filterSchemaNodeForNamespace(namespace, er.SchemaNode)
// Filter the types for the given namespace.
er.Types = filterTypesForNamespace(namespace, er.Types)
}
req.Latency.Processing += time.Since(schemaProcessingStart)
return er, nil
}
// filterTypesForNamespace filters types for the given namespace.
func filterTypesForNamespace(namespace uint64, types []*pb.TypeUpdate) []*pb.TypeUpdate {
out := []*pb.TypeUpdate{}
for _, update := range types {View on GitHub (pinned to 759e242be6)
Solutions
- Verify the type name exists by listing all types first: schema(type: []) or inspect schema output
- Check cluster health and retry after transient network/node issues are fixed
- If the type was renamed in a migration, update client queries and DQL to the new name
- Re-push the schema (POST /admin/schema) if type definitions are missing or corrupt
Example fix
// before: non-existent type
schema(type: [Persn]) { }
// after: correct type name
schema(type: [Person]) { } Defensive patterns
Strategy: validation
Validate before calling
// Verify type exists before requesting it
knownTypes := map[string]bool{"Person": true, "Company": true}
if !knownTypes[typ] {
return fmt.Errorf("unknown type %q; check schema(type: [])", typ)
} Try / catch
er, err := q.ProcessQuery(ctx, req)
if err != nil && strings.Contains(err.Error(), "while fetching types") {
// check cluster health, validate type name, retry
return fmt.Errorf("type fetch failed: %w", err)
} Prevention
- Keep a canonical list of type names shared with client code
- Run schema(type: []) periodically to detect drift after migrations
- Re-push schema after failed migrations
When it happens
Trigger: Query containing schema(type: [TypeName]) or a types request while the cluster cannot serve the types: dead peers, timeout, or referencing a type name that does not exist / cannot be resolved.
Common situations: Typo in type name in the schema query, schema migration left dangling types, cluster health issues similar to schema fetch failures.
Related errors
- unique validation failed to fetch schema for predicates %v
- while fetching schema
- cannot retrieve predicate information
- illegal rune found "%c", expecting {
- JSON map is followed by illegal rune "%c"
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/f3251d968b1b8190.
Report an issue: GitHub.