dgraph-io/dgraph · error
empty variable name in function call
Error message
empty variable name in function call
What it means
Error raised by the RDF parser in chunker/rdf_parser.go when a function call references a variable with an empty name (e.g. fn with no variable identifier). Indicates malformed input; fix by providing the variable name inside the function call.
Source
Thrown at chunker/rdf_parser.go:248
}
// parseFunction parses uid(<var name>) and returns
// uid(<var name>) after striping whitespace if any
func parseFunction(it *lex.ItemIterator) (string, error) {
item := it.Item()
s := item.Val
it.Next()
if item = it.Item(); item.Typ != itemLeftRound {
return "", fmt.Errorf("expected '(', found: %s", item.Val)
}
it.Next()
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)View on GitHub (pinned to 759e242be6)
Solutions
- Supply a real variable name inside the parentheses.
- Fix the template/generator so the variable placeholder is populated before calling ParseRDF.
- Strip or skip lines whose function calls have empty variables before parsing.
Example fix
// before
ParseRDF(fmt.Sprintf("<s> <p> uid(%s) .", varName)) // varName == ""
// after
if varName == "" { return errors.New("varName required") }
ParseRDF(fmt.Sprintf("<s> <p> uid(%s) .", varName)) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(varName) == "" {
return errors.New("variable name must be non-empty")
} Try / catch
if _, err := parseFunction(it); err != nil {
if err.Error() == "empty variable name in function call" {
return fmt.Errorf("populate variable placeholder before parsing: %w", err)
}
return err
} Prevention
- Check template placeholders are filled before rendering query strings.
- Trim and validate variable names at generation time.
- Fail fast in generators when a required variable is missing.
When it happens
Trigger: ParseRDF input where a function call's parentheses contain only whitespace or a token that trims to the empty string, e.g. 'uid( )' or 'uid(\t)'.
Common situations: Templated queries where the variable placeholder was never filled in; generators emitting empty placeholders; accidental deletion of the variable during editing.
Related errors
- NQuad failed sanity check. Subject: %q, Predicate: %q, Objec
- empty facetKeys not allowed
- expected '(', found: %s
- expected variable name, found: %s
- expected ')', found: %s
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/c7cae88c00809efc.
Report an issue: GitHub.