{"record":{"id":"9ddfb91bdc3fd97e","repo":"dgraph-io/dgraph","slug":"unexpected-end-of-iri","errorCode":null,"errorMessage":"Unexpected end of IRI","messagePattern":"Unexpected end of IRI","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lex/iri.go","lineNumber":19,"sourceCode":"/*\n * SPDX-FileCopyrightText: © 2017-2026 Istari Digital, Inc.\n * SPDX-License-Identifier: Apache-2.0\n */\n\npackage lex\n\nimport (\n\t\"github.com/pkg/errors\"\n)\n\n// IRIRef emits an IRIREF or returns an error if the input is invalid.\nfunc IRIRef(l *Lexer, styp ItemType) error {\n\tl.Ignore() // ignore '<'\n\tl.AcceptRunRec(isIRIRefChar)\n\tl.Emit(styp) // will emit without '<' and '>'\n\tr := l.Next()\n\tif r == EOF {\n\t\treturn errors.New(\"Unexpected end of IRI\")\n\t}\n\tif r != '>' {\n\t\treturn errors.Errorf(\"Unexpected character %q while parsing IRI\", r)\n\t}\n\tl.Ignore() // ignore '>'\n\treturn nil\n}\n\n// isIRIRefChar returns whether the rune is a character allowed in an IRIRef.\n// IRIREF ::= '<' ([^#x00-#x20<>\"{}|^`\\] | UCHAR)* '>'\nfunc isIRIRefChar(r rune, l *Lexer) bool {\n\tif r <= 32 { // no chars b/w 0x00 to 0x20 inclusive\n\t\treturn false\n\t}\n\tswitch r {\n\tcase '<', '>', '\"', '{', '}', '|', '^', '`':\n\t\treturn false\n\tcase '\\\\':","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/lex/iri.go#L1-L37","documentation":"The lexer's IRIRef parses `<...>` IRI references (as in N-Quads/Turtle). It reads characters until it expects the closing `>`; if input ends (EOF) before the closing bracket, the IRI is unterminated and this error is returned.","triggerScenarios":"lexing an RDF/N-Quads document containing `<http://example.com/x` with no closing `>`, e.g. truncated input or a line/record cut off mid-IRI.","commonSituations":"Truncated file uploads, network cuts mid-stream, log records missing the terminator, or hand-edited RDF files with unbalanced angle brackets.","solutions":["Fix the input so the IRI is closed with a `>`","Validate/sanitize the RDF document before lexing","Check for truncation at the source (upload, network, file write)","Escape or reject records containing bare `<` that isn't an IRI start"],"exampleFix":"// before\n<http://example.com/s> <http://example.com/p \"value\" .\n// after\n<http://example.com/s> <http://example.com/p> \"value\" .","handlingStrategy":"validation","validationCode":"if !strings.Contains(line, \">\") && strings.Contains(line, \"<\") {\n  return errors.New(\"unterminated IRI in input\")\n}","typeGuard":null,"tryCatchPattern":"if err := lex.IRIRef(l, item); err != nil {\n  if err.Error() == \"Unexpected end of IRI\" {\n    return fmt.Errorf(\"truncated input at offset %d: %w\", l.Pos(), err)\n  }\n  return err\n}","preventionTips":["Validate RDF documents for balanced angle brackets before lexing","Check upload/stream integrity to prevent truncation","Reject records missing the closing > at ingest time"],"tags":["lexer","rdf","parsing","truncated-input"],"backgroundTag":"unterminated-iri","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}