{"record":{"id":"fdaaca13a0379133","repo":"dgraph-io/dgraph","slug":"expected-but-found-v-at-facet","errorCode":null,"errorMessage":"expected '(' but found %v at facet","messagePattern":"expected '\\(' but found (.+?) at facet","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chunker/rdf_parser.go","lineNumber":266,"sourceCode":"\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() {\n\t\t\treturn errors.New(\"unexpected end of facets\")\n\t\t}\n\t\titem = it.Item()\n\t\tif item.Typ != itemEqual {","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/chunker/rdf_parser.go#L248-L284","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\n\"<s> <p> \\\"v\\\" score=0.9 .\"\n// after\n\"<s> <p> \\\"v\\\" (score=0.9) .\"","handlingStrategy":"validation","validationCode":"func facetSyntaxOK(line string) bool {\n\ti := strings.Index(line, \"\\\"\")\n\trest := line[i+1:]\n\tif j := strings.LastIndex(rest, \"\\\"\"); j >= 0 {\n\t\tafter := strings.TrimSpace(rest[j+1:])\n\t\treturn after == \".\" || strings.HasPrefix(after, \"(\")\n\t}\n\treturn true\n}","typeGuard":null,"tryCatchPattern":"if _, err := ParseRDF(line); err != nil {\n\tif strings.Contains(err.Error(), \"expected '(' but found\") {\n\t\treturn fmt.Errorf(\"facets must be wrapped in parentheses: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["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."],"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"}