{"record":{"id":"60be02055a7b56d5","repo":"dgraph-io/dgraph","slug":"expected-key-but-found-v","errorCode":null,"errorMessage":"expected key but found %v","messagePattern":"expected key but found (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chunker/rdf_parser.go","lineNumber":273,"sourceCode":"\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 {\n\t\t\treturn fmt.Errorf(\"expected = after facetKey. Found %v\", item.Val)\n\t\t}\n\t\t// parse value or empty value\n\t\tif !it.Next() {\n\t\t\treturn errors.New(\"unexpected end of facets\")\n\t\t}\n\t\titem = it.Item()","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/chunker/rdf_parser.go#L255-L291","documentation":"Error raised by the RDF parser in chunker/rdf_parser.go when a facet key (predicate) is expected but the token found is not a valid key; the offending value is reported via %v. Fix by providing a valid facet predicate name.","triggerScenarios":"ParseRDF input where the first token inside the facet parens is not a text key, e.g. '(=0.9)' with a missing key, or '(\"score\"=0.9)' where quotes produce a different token type.","commonSituations":"Facet pairs written value-first; keys quoted when they should be bare text; commas or operators mis-tokenized as keys.","solutions":["Ensure each facet pair starts with a bare text key: (score=0.9).","Remove quotes around facet keys.","Reorder pairs so the key precedes '='."],"exampleFix":"// before\n\"<s> <p> \\\"v\\\" (=0.9) .\"\n// after\n\"<s> <p> \\\"v\\\" (score=0.9) .\"","handlingStrategy":"validation","validationCode":"func facetPairOK(pair string) bool {\n\tparts := strings.SplitN(pair, \"=\", 2)\n\treturn len(parts) == 2 && strings.TrimSpace(parts[0]) != \"\"\n}","typeGuard":null,"tryCatchPattern":"if _, err := ParseRDF(line); err != nil {\n\tif strings.Contains(err.Error(), \"expected key but found\") {\n\t\treturn fmt.Errorf(\"each facet needs a bare text key before '=': %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Emit facets strictly as key=value pairs.","Never quote facet keys in RDF facet syntax.","Validate facet pairs with a key=value regex before parsing."],"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"}