dgraph-io/dgraph · error
Empty predicate
Error message
Empty predicate
What it means
schema.Load reads the latest schema for a predicate from the DB, and rejects an empty predicate name outright with 'Empty predicate'. It is a defensive guard: no DB lookup is attempted without a valid predicate key.
Source
Thrown at schema/schema.go:533
}
// IndexingInProgress checks whether indexing is going on for a given predicate.
func (s *state) IndexingInProgress() bool {
s.RLock()
defer s.RUnlock()
return len(s.mutSchema) > 0
}
// Init resets the schema state, setting the underlying DB to the given pointer.
func Init(ps *badger.DB) {
pstore = ps
reset()
}
// Load reads the latest schema for the given predicate from the DB.
func Load(predicate string) error {
if len(predicate) == 0 {
return errors.Errorf("Empty predicate")
}
State().DeleteMutSchema(predicate)
key := x.SchemaKey(predicate)
txn := pstore.NewTransactionAt(math.MaxUint64, false)
defer txn.Discard()
item, err := txn.Get(key)
if err == badger.ErrKeyNotFound || err == badger.ErrBannedKey {
return nil
}
if err != nil {
return err
}
var s pb.SchemaUpdate
err = item.Value(func(val []byte) error {
x.Check(proto.Unmarshal(val, &s))
return nil
})
if err != nil {View on GitHub (pinned to 759e242be6)
Solutions
- Ensure the predicate string is non-empty before calling schema.Load
- Validate/trim inputs derived from key parsing; reject keys with empty predicate segments
- Guard user-facing inputs so an empty predicate cannot reach Load
Example fix
// before
err := schema.Load(pred) // pred may be ""
// after
if pred == "" {
return fmt.Errorf("skipping Load: empty predicate")
}
err := schema.Load(pred) Defensive patterns
Strategy: validation
Validate before calling
func loadPredicate(pred string) error {
if strings.TrimSpace(pred) == "" {
return fmt.Errorf("refusing Load: empty predicate")
}
return schema.Load(pred)
} Try / catch
if err := schema.Load(pred); err != nil {
if strings.Contains(err.Error(), "Empty predicate") {
log.Warn("skipping schema load for empty predicate key")
return nil
}
return err
} Prevention
- Validate non-empty predicate names before any schema.Load call
- Sanitize predicates parsed from raw keys; reject empty segments
- Trim user input before it reaches schema APIs
When it happens
Trigger: Calling schema.Load("") directly, or indirectly via populateKeyValues/anonymous callers that pass an empty predicate parsed from a bad key.
Common situations: Parsing corrupted or malformed posting-list keys where the predicate segment is empty; passing an unvalidated user-supplied predicate name into Load; off-by-one key parsing in custom tooling.
Related errors
- Field with value type OBJECT must specify the name of the ob
- illegal rune found "%c", expecting {
- JSON map is followed by illegal rune "%c"
- Malformed JSON
- NQuad failed sanity check. Subject: %q, Predicate: %q, Objec
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/6c4be5af06b40e16.
Report an issue: GitHub.