{"record":{"id":"fdfbec6180e95b8a","repo":"stanfordnlp/CoreNLP","slug":"error-reading-from-this-filename","errorCode":null,"errorMessage":"Error reading from \" + this.filename","messagePattern":"Error reading from \" \\+ this\\.filename","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/edu/stanford/nlp/pipeline/AnnotationIterator.java","lineNumber":105,"sourceCode":"                }\n            } else if (format.equals(\"json\")) {\n                Annotation annotation = readJsonDocument(IOUtils.slurpReader(this.br));\n                this.close();\n                docCnt++;\n                return annotation;\n            } else if (format.equals(\"jsonl\")) {\n                String line = br.readLine();\n                while (line != null) {\n                    line = line.trim();\n                    if (!line.isEmpty()) {\n                        Annotation annotation = readJsonDocument(line);\n                        docCnt++;\n                        return annotation;\n                    }\n                }\n            }\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Error reading from \" + this.filename, ex);\n        }\n        return null;\n    }\n\n    public int getDocCnt() {\n        return docCnt;\n    }\n\n    public void close() {\n        if (br != null) {\n            IOUtils.closeIgnoringExceptions(br);\n            br = null;\n        }\n        if (input != null) {\n            IOUtils.closeIgnoringExceptions(input);\n            input = null;\n        }\n    }","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/AnnotationIterator.java#L87-L123","documentation":"readNextDocument wraps all exceptions encountered while parsing the next serialized annotation into RuntimeException with message 'Error reading from <filename>', chaining the original cause. It signals a malformed or truncated input file rather than a normal end-of-iteration.","triggerScenarios":"Corrupt or truncated .jsonl/.proto file, bytes not matching the chosen serializer (e.g. JSON lines fed to the proto path), IO failure mid-file, deserialization exceptions thrown by the AnnotationSerializer.","commonSituations":"Files cut short by interrupted jobs, hand-edited JSONL, wrong extension causing wrong serializer selection, encoding corruption, partial downloads.","solutions":["Inspect the chained cause (ex.getCause()) to see the actual parse/IO failure","Validate the file is complete and regenerated by the same serializer that produced it (e.g. re-run CoreNLP output)","Verify the extension matches the actual content format (.jsonl vs .proto)","Check file permissions and disk integrity; test reading with a fresh small file"],"exampleFix":"// before\nAnnotationIterator it = new AnnotationIterator(\"partial.jsonl\");\n// after\n// regenerate/complete the file first, then:\nAnnotationIterator it = new AnnotationIterator(\"complete.jsonl\");","handlingStrategy":"try-catch","validationCode":"File f = new File(filename);\nif (!f.isFile() || f.length() == 0)\n  throw new IllegalArgumentException(\"Missing/empty annotation file: \" + filename);","typeGuard":null,"tryCatchPattern":"try {\n  iterateAll(it);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Error reading from\")) {\n    log.error(\"Corrupt input \" + filename + \": \" + e.getCause());\n  } else throw e;\n}","preventionTips":["Regenerate truncated files fully before reading","Match file extension to actual serialization format","Log and inspect getCause() for the root failure","Validate JSONL lines with a quick parse pass first"],"tags":["io","deserialization","pipeline","java"],"backgroundTag":"file-read-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}