dgraph-io/dgraph · error
unexpected end of facets
Error message
unexpected end of facets
What it means
Error raised by the RDF parser in chunker/rdf_parser.go when facet parsing reaches the end of the input before the facet list is complete. Indicates truncated or malformed facet data; fix by supplying the complete facet list in the statement.
Source
Thrown at chunker/rdf_parser.go:262
if item = it.Item(); item.Typ != itemVarName {
return "", fmt.Errorf("expected variable name, found: %s", item.Val)
}
if strings.TrimSpace(item.Val) == "" {
return "", errors.New("empty variable name in function call")
}
s += "(" + item.Val + ")"
it.Next()
if item = it.Item(); item.Typ != itemRightRound {
return "", fmt.Errorf("expected ')', found: %s", item.Val)
}
return s, nil
}
func parseFacetsRDF(it *lex.ItemIterator, rnq *api.NQuad) error {
if !it.Next() {
return errors.New("unexpected end of facets")
}
item := it.Item()
if item.Typ != itemLeftRound {
return fmt.Errorf("expected '(' but found %v at facet", item.Val)
}
for it.Next() { // parse one key value pair
// parse key
item = it.Item()
if item.Typ != itemText {
return fmt.Errorf("expected key but found %v", item.Val)
}
facetKey := strings.TrimSpace(item.Val)
if len(facetKey) == 0 {
return errors.New("empty facetKeys not allowed")
}
// parse =
if !it.Next() {View on GitHub (pinned to 759e242be6)
Solutions
- Complete the facet section so it has '(key=value)' content after the object.
- Remove any dangling facet marker if facets were not intended.
- Validate each line ends cleanly (with the terminating '.') before parsing.
Example fix
// before
"<s> <p> \"v\" (" // dangling '(' with nothing after
// after
"<s> <p> \"v\" (score=0.9) ." Defensive patterns
Strategy: validation
Validate before calling
func facetsComplete(line string) bool {
return strings.Count(line, "(") == strings.Count(line, ")")
} Try / catch
if _, err := ParseRDF(line); err != nil {
if err.Error() == "unexpected end of facets" {
return fmt.Errorf("incomplete facet section in line %q", redact(line))
}
return err
} Prevention
- Balance-check parens per line before import.
- Ensure files end with complete lines (no partial writes).
- Include the terminating '.' on every N-Quads statement.
When it happens
Trigger: ParseRDF input where a '(' was expected to start facets but the line ended immediately after the object value, e.g. a dangling facet marker or a line cut off after the object.
Common situations: Truncated .nq files; streaming parsers that split lines mid-facet; generators that emit the facet opener without content.
Related errors
- expected '(' but found %v at facet
- expected key but found %v
- empty facetKeys not allowed
- NQuad failed sanity check. Subject: %q, Predicate: %q, Objec
- expected '(', found: %s
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/6d1a22f512388008.
Report an issue: GitHub.