{"record":{"id":"f3251d968b1b8190","repo":"dgraph-io/dgraph","slug":"while-fetching-types","errorCode":null,"errorMessage":"while fetching types","messagePattern":"while fetching types","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/query.go","lineNumber":3072,"sourceCode":"\tfor _, sg := range er.Subgraphs {\n\t\tcalculateMetrics(sg, metrics)\n\t}\n\ter.Metrics = metrics\n\tnamespace, err := x.ExtractNamespace(ctx)\n\tif err != nil {\n\t\treturn er, errors.Wrapf(err, \"While processing query\")\n\t}\n\tschemaProcessingStart := time.Now()\n\tif req.DqlQuery.Schema != nil {\n\t\tpreds := x.NamespaceAttrList(namespace, req.DqlQuery.Schema.Predicates)\n\t\treq.DqlQuery.Schema.Predicates = preds\n\t\tif er.SchemaNode, err = worker.GetSchemaOverNetwork(ctx, req.DqlQuery.Schema); err != nil {\n\t\t\treturn er, errors.Wrapf(err, \"while fetching schema\")\n\t\t}\n\t\ttypeNames := x.NamespaceAttrList(namespace, req.DqlQuery.Schema.Types)\n\t\treq.DqlQuery.Schema.Types = typeNames\n\t\tif er.Types, err = worker.GetTypes(ctx, req.DqlQuery.Schema); err != nil {\n\t\t\treturn er, errors.Wrapf(err, \"while fetching types\")\n\t\t}\n\t}\n\n\tif !x.IsRootNsOperation(ctx) {\n\t\t// Filter the schema nodes for the given namespace.\n\t\ter.SchemaNode = filterSchemaNodeForNamespace(namespace, er.SchemaNode)\n\t\t// Filter the types for the given namespace.\n\t\ter.Types = filterTypesForNamespace(namespace, er.Types)\n\t}\n\treq.Latency.Processing += time.Since(schemaProcessingStart)\n\n\treturn er, nil\n}\n\n// filterTypesForNamespace filters types for the given namespace.\nfunc filterTypesForNamespace(namespace uint64, types []*pb.TypeUpdate) []*pb.TypeUpdate {\n\tout := []*pb.TypeUpdate{}\n\tfor _, update := range types {","sourceCodeStart":3054,"sourceCodeEnd":3090,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/query/query.go#L3054-L3090","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typo in type name in the schema query, schema migration left dangling types, cluster health issues similar to schema fetch failures.","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"],"exampleFix":"// before: non-existent type\nschema(type: [Persn]) { }\n// after: correct type name\nschema(type: [Person]) { }","handlingStrategy":"validation","validationCode":"// Verify type exists before requesting it\nknownTypes := map[string]bool{\"Person\": true, \"Company\": true}\nif !knownTypes[typ] {\n    return fmt.Errorf(\"unknown type %q; check schema(type: [])\", typ)\n}","typeGuard":null,"tryCatchPattern":"er, err := q.ProcessQuery(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"while fetching types\") {\n    // check cluster health, validate type name, retry\n    return fmt.Errorf(\"type fetch failed: %w\", err)\n}","preventionTips":["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"],"tags":["schema","types","network","dgraph"],"backgroundTag":"schema-fetch-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}