dgraph-io/dgraph · error
Repeated id with non int/float value for facet var encounter
Error message
Repeated id with non int/float value for facet var encountered.
What it means
When propagating facet value variables across repeated UIDs (same id appearing multiple times), Dgraph sums facet values and requires them to be int or float. If facets.ValFor returns a value of another type (e.g. datetime, string, bool), this error is thrown because 'sum' aggregation over repeated ids cannot handle non-numeric facet values.
Source
Thrown at query/query.go:1721
continue
}
if pVal, ok := doneVars[fvar].Vals.Get(uid); !ok {
fVal, err := facets.ValFor(f)
if err != nil {
return err
}
doneVars[fvar].Vals.Set(uid, fVal)
} else {
// If the value is int/float we add them up. Else we throw an error as
// many to one maps are not allowed for other types.
nVal, err := facets.ValFor(f)
if err != nil {
return err
}
if nVal.Tid != types.IntID && nVal.Tid != types.FloatID {
return errors.Errorf("Repeated id with non int/float value for " +
"facet var encountered.")
}
ag := aggregator{name: "sum"}
if err := ag.Apply(pVal); err != nil {
return err
}
if err := ag.Apply(nVal); err != nil {
return err
}
fVal, err := ag.Value()
if err != nil {
continue
}
doneVars[fvar].Vals.Set(uid, fVal)
}
}
}
}View on GitHub (pinned to 759e242be6)
Solutions
- Ensure the facet used in the facet variable has an int or float type
- Change the facet value type in the schema or write numeric values for that facet
- Remove the facet variable usage if non-numeric facets are required and handle client-side
- Deduplicate the UID list so the repeated-id summation path is not taken
Example fix
// before: 'since' facet is datetime
{
me(func: uid(1)) {
friend @facets(s as since)
}
}
// after: use a numeric facet
{
me(func: uid(1)) {
friend @facets(s as weight) // weight is float
}
} Defensive patterns
Strategy: validation
Validate before calling
// Confirm facet types are numeric before using facet variables in aggregation
if facetType(pred, facet) != "int" && facetType(pred, facet) != "float" {
return fmt.Errorf("facet %s on %s must be int/float for facet variables", facet, pred)
} Type guard
func isNumericFacet(v types.Val) bool { return v.Tid == types.IntID || v.Tid == types.FloatID } Try / catch
if err != nil && strings.Contains(err.Error(), "non int/float value for facet var") {
return fmt.Errorf("facet variable used with non-numeric facet: %w", err)
} Prevention
- Declare numeric facets as int/float in schema when they will be aggregated
- Avoid datetime/string facets in facet-variable positions
- Validate facet types in data-ingestion pipelines
When it happens
Trigger: Using a facet variable (facet var) on a predicate with duplicate UIDs where the facet's type is not int/float; e.g. 'friend @facets(since as f)' where f is a datetime facet and the same friend id repeats in the uid list.
Common situations: Facets declared as datetime/string/bool in schema but used with facet variables in aggregation contexts; queries assuming facets are numeric; schema evolved to non-numeric facet types.
Related errors
- Error in applying aggregation %s
- UID must be present and non-zero while deleting edges
- facet value can only be string/number/bool
- facets format should be of type map for scalarlist predicate
- unexpected end of facets
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/9f55a66002b43807.
Report an issue: GitHub.