{"record":{"id":"2101c9fac5f23399","repo":"stanfordnlp/CoreNLP","slug":"unsupported-file-format-filename","errorCode":null,"errorMessage":"Unsupported file format: \" + filename","messagePattern":"Unsupported file format: \" \\+ filename","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/AnnotationIterator.java","lineNumber":44,"sourceCode":"    JSONAnnotationReader jsonReader = new JSONAnnotationReader();\n    String format;\n    int docCnt = 0;\n    int limit = 0;\n\n    public AnnotationIterator(String filename) throws IOException {\n        this.filename = filename;\n        if (filename.endsWith(\".json\")) {\n            this.br = IOUtils.readerFromString(filename);\n            this.format = \"json\";\n        } else if (filename.endsWith(\".jsonl\")) {\n            this.br = IOUtils.readerFromString(filename);\n            this.format = \"jsonl\";\n        } else if (filename.endsWith(\".proto\")) {\n            this.input = IOUtils.getFileInputStream(filename);\n            this.serializer = new ProtobufAnnotationSerializer();\n            this.format = \"proto\";\n        } else {\n            throw new IOException(\"Unsupported file format: \" + filename);\n        }\n        nextDoc = readNextDocument();\n    }\n\n    public AnnotationIterator(String filename, int limit) throws IOException {\n        this(filename);\n        this.limit = limit;\n    }\n\n    @Override\n    public boolean hasNext() {\n        return nextDoc != null;\n    }\n\n    @Override\n    public Annotation next() {\n        if (nextDoc == null) {\n            throw new NoSuchElementException(\"DocumentIterator exhausted.\");","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/AnnotationIterator.java#L26-L62","documentation":"AnnotationIterator's constructor dispatches on filename extension (.jsonl, .proto, etc.) to choose the input stream and serializer; an unrecognized extension throws IOException since it cannot decide how to deserialize annotations.","triggerScenarios":"Constructing AnnotationIterator (or AnnotationOutputter-driven pipelines reading a corpus file) with a path not ending in a supported extension such as .jsonl or .proto.","commonSituations":"Passing a .json file where .jsonl is expected, an extensionless file, .txt dumps, or a compressed variant (.gz) the constructor doesn't recognize.","solutions":["Rename the file to have a supported extension: .jsonl for JSON Lines or .proto for protobuf serialization","Convert your corpus to JSON Lines or protobuf-serialized annotations first","Check for trailing characters in the path (quotes, whitespace, .gz suffix) that break endsWith","If reading serialized annotations, serialize them with ProtobufAnnotationSerializer or the JSON outputter to match the extension"],"exampleFix":"// before\nAnnotationIterator it = new AnnotationIterator(\"docs.json\");\n// after\nAnnotationIterator it = new AnnotationIterator(\"docs.jsonl\");","handlingStrategy":"validation","validationCode":"String lower = filename.toLowerCase();\nif (!lower.endsWith(\".jsonl\") && !lower.endsWith(\".proto\")) {\n  throw new IllegalArgumentException(\"Rename to .jsonl or .proto: \" + filename);\n}\nAnnotationIterator it = new AnnotationIterator(filename);","typeGuard":"boolean isSupportedAnnotationFile(String f) {\n  return f != null && (f.endsWith(\".jsonl\") || f.endsWith(\".proto\"));\n}","tryCatchPattern":"try {\n  it = new AnnotationIterator(filename);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Unsupported file format\")) {\n    System.err.println(\"Convert file to .jsonl or .proto first\");\n  } else throw e;\n}","preventionTips":["Rename files to .jsonl or .proto before feeding to CoreNLP","Convert .json (single object) outputs to JSON Lines","Watch for trailing whitespace/quotes in paths","Standardize corpus serialization format"],"tags":["io","file-format","pipeline","java"],"backgroundTag":"unsupported-file-format","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"}