dgraph-io/dgraph · error
expected '(' but found %v at facet
Error message
expected '(' but found %v at facet What it means
Error raised by the RDF parser in chunker/rdf_parser.go while parsing facets when the parser expects an opening '(' for a value but encounters a different token, which is reported via %v. Indicates malformed facet syntax; fix by correcting the facet value format.
Source
Thrown at chunker/rdf_parser.go:266
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() {
return errors.New("unexpected end of facets")
}
item = it.Item()
if item.Typ != itemEqual {View on GitHub (pinned to 759e242be6)
Solutions
- Wrap the facet list in parentheses: (key=value, key2=value2).
- If the trailing token is not a facet, remove it from the line.
- Check the facet syntax documented for RDF parsing: object followed by (key=value).
Example fix
// before "<s> <p> \"v\" score=0.9 ." // after "<s> <p> \"v\" (score=0.9) ."
Defensive patterns
Strategy: validation
Validate before calling
func facetSyntaxOK(line string) bool {
i := strings.Index(line, "\"")
rest := line[i+1:]
if j := strings.LastIndex(rest, "\""); j >= 0 {
after := strings.TrimSpace(rest[j+1:])
return after == "." || strings.HasPrefix(after, "(")
}
return true
} Try / catch
if _, err := ParseRDF(line); err != nil {
if strings.Contains(err.Error(), "expected '(' but found") {
return fmt.Errorf("facets must be wrapped in parentheses: %w", err)
}
return err
} Prevention
- Always wrap facet lists in (key=value).
- Don't copy query-language facet syntax into RDF lines.
- Run a sample line through ParseRDF before large imports.
When it happens
Trigger: ParseRDF input where a token follows the object that was meant as a facet but is not parenthesized, e.g. '<s> <p> "v" score=0.9 .' — the parser sees 'score' where '(' was required.
Common situations: Writing facets without wrapping them in parentheses; copying facet syntax from query language instead of RDF facet syntax; language tags or datatype suffixes misread as facet starts.
Related errors
- unexpected end of facets
- 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/fdaaca13a0379133.
Report an issue: GitHub.