{"record":{"id":"bca8742b038f2242","repo":"dgraph-io/dgraph","slug":"expected-found-s","errorCode":null,"errorMessage":"expected '(', found: %s","messagePattern":"expected '\\(', found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chunker/rdf_parser.go","lineNumber":240,"sourceCode":"\t}\n\tif !sane(rnq.Subject) || !sane(rnq.Predicate) || !sane(rnq.ObjectId) {\n\t\t// Don't format the full line, as it may contain sensitive information\n\t\treturn rnq, fmt.Errorf(\"NQuad failed sanity check. Subject: %q, Predicate: %q, ObjectId: %q\",\n\t\t\trnq.Subject, rnq.Predicate, rnq.ObjectId)\n\t}\n\n\treturn rnq, nil\n}\n\n// parseFunction parses uid(<var name>) and returns\n// uid(<var name>) after striping whitespace if any\nfunc parseFunction(it *lex.ItemIterator) (string, error) {\n\titem := it.Item()\n\ts := item.Val\n\n\tit.Next()\n\tif item = it.Item(); item.Typ != itemLeftRound {\n\t\treturn \"\", fmt.Errorf(\"expected '(', found: %s\", item.Val)\n\t}\n\n\tit.Next()\n\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}","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/chunker/rdf_parser.go#L222-L258","documentation":"parseFunction parses a function token produced by the RDF lexer and expects an opening parenthesis immediately after the function name. If the next lexer item is not '(', parsing aborts with this message showing the offending token.","triggerScenarios":"Calling ParseRDF on a line containing a malformed function expression, e.g. a function name token not followed by '(' — such as 'uid 0x1' or truncated input where the '(' was dropped.","commonSituations":"Hand-edited RDF/mutation lines where a function call like uid(...) lost its parenthesis; copy-paste errors from docs; lexer treating unexpected characters as a separate token.","solutions":["Check the token printed in the error and add the missing '(' right after the function name.","Verify the whole function expression is well-formed: name(variable).","Re-escape or re-quote the line if shell or templating stripped characters before reaching ParseRDF."],"exampleFix":"// before\nParseRDF(\"<s> <p> uid var .\")     // 'uid var' missing '('\n// after\nParseRDF(\"<s> <p> uid(var) .\")","handlingStrategy":"validation","validationCode":"func validFunctionCall(s string) bool {\n\ti := strings.Index(s, \"(\")\n\treturn i > 0 && strings.HasSuffix(s, \")\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := parseFunction(it); err != nil {\n\tif strings.HasPrefix(err.Error(), \"expected '('\") {\n\t\treturn fmt.Errorf(\"malformed function in RDF line: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Write function calls as name(variable) with both parentheses.","Avoid hand-editing RDF lines containing function expressions.","Escape input through shells/templates carefully so parens survive.","Test generated lines with ParseRDF in CI before bulk import."],"tags":["rdf","parsing","syntax","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"}