dgraph-io/dgraph · error
failed to enrich schema
Error message
failed to enrich schema
What it means
When the parser reaches EOF it finalizes the schema by running resolveTokenizers over all parsed predicates, which validates that requested index tokenizers exist and are applicable. If that fails, parse wraps it as 'failed to enrich schema'. The root cause is in the wrapped inner error (an invalid or unknown tokenizer/index).
Source
Thrown at schema/parse.go:672
result.Types = append(result.Types, typeUpdate)
return nil
}
schema, err := parseScalarPair(it, item.Val, ns)
if err != nil {
return err
}
result.Preds = append(result.Preds, schema)
return nil
}
it := l.NewIterator()
for it.Next() {
item := it.Item()
switch item.Typ {
case lex.ItemEOF:
if err := resolveTokenizers(result.Preds); err != nil {
return nil, errors.Wrapf(err, "failed to enrich schema")
}
return &result, nil
case itemText:
// For schema which does not contain the namespace information, use the default
// namespace, if namespace has to be preserved. Else, use the passed namespace.
ns := x.RootNamespace
if namespace != math.MaxUint64 {
ns = namespace
}
if err := parseTypeOrSchema(item, it, ns); err != nil {
return nil, err
}
case itemLeftSquare:
// We expect a namespace.
ns, err := parseNamespace(it)
if err != nil {View on GitHub (pinned to 759e242be6)
Solutions
- Read the inner error (err chain) to identify the offending predicate and tokenizer
- Correct the @index(...) directive to a valid tokenizer for the predicate's type (e.g. @index(exact) for string, @index(int) for int)
- Check the Dgraph docs for tokenizers supported by your version
- Validate the schema with a dry run against a test instance before applying
Example fix
// before schema := "age: int @index(hash) ." // hash is not valid for int // after schema := "age: int @index(int) ."
Defensive patterns
Strategy: validation
Validate before calling
validTokenizers := map[string]bool{"exact":true,"hash":true,"term":true,"fulltext":true,"trigram":true,"int":true,"float":true,"bool":true,"datetime":true}
for _, d := range indexDirectives(schemaStr) {
if !validTokenizers[d] {
return fmt.Errorf("unknown tokenizer: %s", d)
}
} Try / catch
if _, err := schema.Parse(s, 0, 1); err != nil {
var inner error
if errors.Unwrap(err) != nil { inner = errors.Unwrap(err) }
return fmt.Errorf("tokenizer enrichment failed (check @index directives): %w", inner)
} Prevention
- Cross-check @index tokenizers against the type of each predicate
- Keep a curated list of tokenizers valid for your Dgraph version
- Test schema changes on a staging instance first
When it happens
Trigger: Schema.Parse / ParseWithNamespace / ToDirectedEdges called with a schema declaring an index whose tokenizer name is misspelled or inapplicable to the type, e.g. 'hash' index on a float or a nonexistent tokenizer name.
Common situations: Typos in @index(hash) / @index(term) directives; using a tokenizer removed or not yet available in the Dgraph version; applying a string-only index to a dateTime/int predicate.
Related errors
- Require type of tokenizer for pred: %s of type: %s for index
- Tokenizers present without indexing on attr %s
- Tokenizer must be specified while indexing a predicate: %+v
- Directive must be SchemaUpdate_INDEX when a tokenizer is spe
- illegal rune found "%c", expecting {
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/6784f3f977df454a.
Report an issue: GitHub.