{"record":{"id":"6d1a22f512388008","repo":"dgraph-io/dgraph","slug":"unexpected-end-of-facets","errorCode":null,"errorMessage":"unexpected end of facets","messagePattern":"unexpected end of facets","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chunker/rdf_parser.go","lineNumber":262,"sourceCode":"\tif item = it.Item(); item.Typ != itemVarName {\n\t\treturn \"\", fmt.Errorf(\"expected variable name, found: %s\", item.Val)\n\t}\n\tif strings.TrimSpace(item.Val) == \"\" {\n\t\treturn \"\", errors.New(\"empty variable name in function call\")\n\t}\n\ts += \"(\" + item.Val + \")\"\n\n\tit.Next()\n\tif item = it.Item(); item.Typ != itemRightRound {\n\t\treturn \"\", fmt.Errorf(\"expected ')', found: %s\", item.Val)\n\t}\n\n\treturn s, nil\n}\n\nfunc parseFacetsRDF(it *lex.ItemIterator, rnq *api.NQuad) error {\n\tif !it.Next() {\n\t\treturn errors.New(\"unexpected end of facets\")\n\t}\n\titem := it.Item()\n\tif item.Typ != itemLeftRound {\n\t\treturn fmt.Errorf(\"expected '(' but found %v at facet\", item.Val)\n\t}\n\n\tfor it.Next() { // parse one key value pair\n\t\t// parse key\n\t\titem = it.Item()\n\t\tif item.Typ != itemText {\n\t\t\treturn fmt.Errorf(\"expected key but found %v\", item.Val)\n\t\t}\n\t\tfacetKey := strings.TrimSpace(item.Val)\n\t\tif len(facetKey) == 0 {\n\t\t\treturn errors.New(\"empty facetKeys not allowed\")\n\t\t}\n\t\t// parse =\n\t\tif !it.Next() {","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/chunker/rdf_parser.go#L244-L280","documentation":"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.","triggerScenarios":"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.","commonSituations":"Truncated .nq files; streaming parsers that split lines mid-facet; generators that emit the facet opener without content.","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."],"exampleFix":"// before\n\"<s> <p> \\\"v\\\" (\"           // dangling '(' with nothing after\n// after\n\"<s> <p> \\\"v\\\" (score=0.9) .\"","handlingStrategy":"validation","validationCode":"func facetsComplete(line string) bool {\n\treturn strings.Count(line, \"(\") == strings.Count(line, \")\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := ParseRDF(line); err != nil {\n\tif err.Error() == \"unexpected end of facets\" {\n\t\treturn fmt.Errorf(\"incomplete facet section in line %q\", redact(line))\n\t}\n\treturn err\n}","preventionTips":["Balance-check parens per line before import.","Ensure files end with complete lines (no partial writes).","Include the terminating '.' on every N-Quads statement."],"tags":["rdf","parsing","facets","dgraph"],"backgroundTag":"parser-syntax-error","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}