dgraph-io/dgraph · error · errEmptyUID

UID must be present and non-zero while deleting edges

Error message

UID must be present and non-zero while deleting edges

What it means

The exact tokenizer only accepts Go string values; Tokens() does a type assertion v.(string) and errors for anything else. Exact indices are string-only by design, so non-string scalar values (int, float, bool, datetime) cannot be tokenized.

Source

Thrown at chunker/json_parser.go:30

	"fmt"
	"math/rand"
	"strconv"
	"strings"
	"sync/atomic"
	"unicode"

	"github.com/twpayne/go-geom"
	"github.com/twpayne/go-geom/encoding/geojson"

	"github.com/dgraph-io/dgo/v250/protos/api"
	"github.com/dgraph-io/dgraph/v25/protos/pb"
	"github.com/dgraph-io/dgraph/v25/types"
	"github.com/dgraph-io/dgraph/v25/types/facets"
	"github.com/dgraph-io/dgraph/v25/x"
	"github.com/dgraph-io/simdjson-go"
)

var errEmptyUID = errors.New("UID must be present and non-zero while deleting edges")

func stripSpaces(str string) string {
	return strings.Map(func(r rune) rune {
		if unicode.IsSpace(r) {
			return -1
		}

		return r
	}, str)
}

// handleBasicFacetsType parses a facetVal to string/float64/bool/datetime type.
func handleBasicFacetsType(key string, facetVal interface{}) (*api.Facet, error) {
	var jsonValue interface{}
	var valueType api.Facet_ValType
	switch v := facetVal.(type) {
	case string:
		if t, err := types.ParseTime(v); err == nil {

View on GitHub (pinned to 759e242be6)

Solutions

  1. Change the predicate type in the schema to string if exact indexing is needed, or remove @index(exact) from non-string predicates.
  2. Convert the value to a string before tokenizing if string comparison semantics are acceptable.
  3. Use the appropriate tokenizer/type combination (e.g. int predicates need no exact tokenizer).

Example fix

// before
pred: "age" @index(exact) . // age is int
tok.ExactTokenizer{}.Tokens(42) // error
// after
pred: "name" @index(exact) .
tok.ExactTokenizer{}.Tokens("alice")
Defensive patterns

Strategy: type-guard

Validate before calling

if s, ok := v.(string); !ok {
    return fmt.Errorf("exact tokenizer requires string, got %T", v)
}

Type guard

func isString(v interface{}) bool { _, ok := v.(string); return ok }

Try / catch

tokens, err := exactTok.Tokens(v)
if err != nil && strings.Contains(err.Error(), "only supported for string types") {
    return nil, fmt.Errorf("predicate must be string type for exact index; got %T", v)
}

Prevention

When it happens

Trigger: Calling ExactTokenizer.Tokens(v) with a value whose dynamic type is not string — e.g. passing an int64/float64/bool into tokenization for a predicate indexed as exact.

Common situations: Schema declares @index(exact) on an int/float/bool/datetime predicate; code path feeding raw values to the tokenizer without converting to string first.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/02261d5ea2fde9c8. Report an issue: GitHub.