{"record":{"id":"245561304db44bd4","repo":"dgraph-io/dgraph","slug":"unexpected-end-of-input","errorCode":null,"errorMessage":"Unexpected end of input.","messagePattern":"Unexpected end of input\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lex/lexer.go","lineNumber":405,"sourceCode":"\treturn false\n}\n\n// IsEndOfLine returns true if the rune is a Linefeed or a Carriage return.\nfunc IsEndOfLine(r rune) bool {\n\treturn r == '\\u000A' || r == '\\u000D'\n}\n\n// LexQuotedString properly processes a quoted string (by taking care of escaped characters).\nfunc (l *Lexer) LexQuotedString() error {\n\tl.Backup()\n\tr := l.Next()\n\tif r != quote {\n\t\treturn errors.Errorf(\"String should start with quote.\")\n\t}\n\tfor {\n\t\tr := l.Next()\n\t\tif r == EOF {\n\t\t\treturn errors.Errorf(\"Unexpected end of input.\")\n\t\t}\n\t\tif r == '\\\\' {\n\t\t\tr := l.Next()\n\t\t\tif !l.IsEscChar(r) {\n\t\t\t\treturn errors.Errorf(\"Not a valid escape char: '%c'\", r)\n\t\t\t}\n\t\t\tcontinue // eat the next char\n\t\t}\n\t\tif r == quote {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":387,"sourceCodeEnd":420,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/lex/lexer.go#L387-L420","documentation":"LexQuotedString returns 'Unexpected end of input.' when it reaches EOF (rune 0) while scanning a quoted string, meaning the closing quote was never found. Dgraph's lexer requires string literals to be terminated on the same input, so any string that runs to end-of-file without a closing '\"' aborts lexing.","triggerScenarios":"A DQL query or RDF N-Quad mutation contains an opening '\"' with no matching closing quote before the input ends — e.g. truncated request bodies, heredoc/template rendering that dropped the final quote, or a multi-line literal written without escapes.","commonSituations":"Large mutations truncated by proxies or size limits; shell heredocs losing the last character; template engines cutting off output; users editing queries and deleting the closing quote.","solutions":["Add the missing closing double quote to the string literal","Log the full request payload server-side to confirm it is not truncated in transit","Check proxy/gateway body size limits and client serialization","If the literal must span lines or contain quotes, escape them (\\\") rather than leaving unterminated"],"exampleFix":"// before\n{\n  q(func: eq(name, \"Alice))\n}\n// after\n{\n  q(func: eq(name, \"Alice\"))\n}","handlingStrategy":"validation","validationCode":"// Ensure balanced double quotes before sending\nfunc quotesBalanced(s string) bool {\n    inStr, esc := false, false\n    for _, r := range s {\n        if esc { esc = false; continue }\n        if r == '\\\\' { esc = true; continue }\n        if r == '\"' { inStr = !inStr }\n    }\n    return !inStr\n}","typeGuard":null,"tryCatchPattern":"if err := mutate(payload); err != nil && strings.Contains(err.Error(), \"Unexpected end of input\") {\n    return fmt.Errorf(\"unterminated string literal in payload: %w\", err)\n}","preventionTips":["Count quotes / use an editor with DQL syntax highlighting to spot unterminated strings","Check proxy and body-size limits that can truncate large mutation payloads","Log full outgoing payloads to confirm nothing is cut off","Escape embedded quotes as \\\" instead of ending the string early"],"tags":["lexer","string-literal","unterminated","eof"],"backgroundTag":"unterminated-string-literal","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}