{"record":{"id":"6a9c77773d87517c","repo":"stanfordnlp/CoreNLP","slug":"format-error-6a9c77","errorCode":null,"errorMessage":"format error","messagePattern":"format error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifierNonlinear.java","lineNumber":258,"sourceCode":"\n  @Override\n  protected void loadTextClassifier(BufferedReader br) throws Exception {\n    super.loadTextClassifier(br);\n\n    String line = br.readLine();\n    String[] toks = line.split(\"\\\\t\");\n    if (!toks[0].equals(\"nodeFeatureIndicesMap.size()=\")) {\n      throw new RuntimeException(\"format error in nodeFeatureIndicesMap\");\n    }\n    int nodeFeatureIndicesMapSize = Integer.parseInt(toks[1]);\n    nodeFeatureIndicesMap = new HashIndex<>();\n    int count = 0;\n    while (count < nodeFeatureIndicesMapSize) {\n      line = br.readLine();\n      toks = line.split(\"\\\\t\");\n      int idx = Integer.parseInt(toks[0]);\n      if (count != idx) {\n        throw new RuntimeException(\"format error\");\n      }\n      nodeFeatureIndicesMap.add(Integer.parseInt(toks[1]));\n      count++;\n    }\n\n    line = br.readLine();\n    toks = line.split(\"\\\\t\");\n    if (!toks[0].equals(\"edgeFeatureIndicesMap.size()=\")) {\n      throw new RuntimeException(\"format error\");\n    }\n    int edgeFeatureIndicesMapSize = Integer.parseInt(toks[1]);\n    edgeFeatureIndicesMap = new HashIndex<>();\n    count = 0;\n    while (count < edgeFeatureIndicesMapSize) {\n      line = br.readLine();\n      toks = line.split(\"\\\\t\");\n      int idx = Integer.parseInt(toks[0]);\n      if (count != idx) {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifierNonlinear.java#L240-L276","documentation":"While parsing the nodeFeatureIndicesMap section of a text-serialized CRFClassifierNonlinear model, each entry line must be \"<index>\\t<value>\" where the index exactly equals the running count. If the parsed line index does not match the expected sequential position, this RuntimeException is thrown. It indicates entries are missing, duplicated, reordered, or the file is misaligned.","triggerScenarios":"loadTextClassifier reads lines after the nodeFeatureIndicesMap.size() header and encounters an entry whose leading index is not equal to the loop counter count, e.g. a deleted/duplicated line, an out-of-order edit, or misaligned lines after a malformed header elsewhere in the file.","commonSituations":"Hand-edited or diff-merged model files; truncated downloads cutting lines; concatenating model files; a size header that disagrees with the actual number of entries.","solutions":["Regenerate the model file with serializeTextClassifier instead of editing it manually.","Verify each entry line is \"i\\tvalue\" with strictly sequential indices starting at 0.","Check the declared size header matches the actual number of entry lines.","Re-transfer the file if it was truncated or corrupted in transit.","If programmatic merging is needed, rewrite indices sequentially rather than splicing files."],"exampleFix":"// before\n0\t5\n2\t7   // index 1 missing -> format error\n// after\n0\t5\n1\t7","handlingStrategy":"validation","validationCode":"// Validate the nodeFeatureIndicesMap section is sequential before loading:\n// Expected format after the header: lines \"i\\tvalue\" with i = 0..size-1\n// e.g. grep -n \"^[0-9]*\\\\t\" model.txt | awk -F'\\\\t' '$1 != NR-2 {print \"bad index at line\", NR}'","typeGuard":null,"tryCatchPattern":"try {\n  crf = CRFClassifier.getClassifier(modelPath);\n} catch (Exception e) {\n  if (String.valueOf(e.getMessage()).equals(\"format error\")) {\n    throw new IOException(\"Non-sequential or missing entry in model index section: \" + modelPath, e);\n  }\n  throw e;\n}","preventionTips":["Treat serialized model files as immutable artifacts; never edit them.","Verify file integrity (checksum) after transferring models.","Serialize and deserialize with the same library version.","If merging models, rewrite indices sequentially programmatically."],"tags":["serialization","model-loading","format-validation","crf"],"backgroundTag":"unexpected-response-shape","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"}