{"record":{"id":"89fd34c4a133bc90","repo":"apache/hadoop","slug":"internal-error","errorCode":null,"errorMessage":"Internal error","messagePattern":"Internal error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/TFile.java","lineNumber":2218,"sourceCode":"        for (int i = 0; i < entryCount; i++) {\n          size = Utils.readVInt(in);\n          if (size < 0 || size > MAX_INDEX_ENTRY_SIZE) {\n            throw new IOException(\"Index entry size out of range: \" + size);\n          }\n          if (buffer.length < size) {\n            buffer = new byte[size];\n          }\n          in.readFully(buffer, 0, size);\n          TFileIndexEntry idx =\n              new TFileIndexEntry(new DataInputStream(new ByteArrayInputStream(\n                  buffer, 0, size)));\n          index.add(idx);\n          sum += idx.entries();\n          recordNumIndex.add(sum);\n        }\n      } else {\n        if (entryCount != 0) {\n          throw new RuntimeException(\"Internal error\");\n        }\n      }\n      this.comparator = comparator;\n    }\n\n    /**\n     * @param key\n     *          input key.\n     * @return the ID of the first block that contains key >= input key. Or -1\n     *         if no such block exists.\n     */\n    public int lowerBound(RawComparable key) {\n      if (comparator == null) {\n        throw new RuntimeException(\"Cannot search in unsorted TFile\");\n      }\n\n      if (firstKey == null) {\n        return -1; // not found","sourceCodeStart":2200,"sourceCodeEnd":2236,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/TFile.java#L2200-L2236","documentation":"RuntimeException(\"Internal error\") from TFileIndex(DataInput): the first-key entry size decoded to <= 0 (meaning 'no first key') but entryCount != 0. The format invariant is that an index with at least one block must carry a first key; an empty first key is only legal for a zero-block (empty) file. Violating that pairing means the index header itself is inconsistent.","triggerScenarios":"A corrupt or malformed index where size <= 0 coexists with a nonzero block count: zeroed-out index bytes after truncation, or a hand-crafted/nonconforming TFile. It is explicitly labeled 'Internal error' because well-formed writers cannot produce this combination.","commonSituations":"Files damaged in ways that zero header bytes (some filesystem corruption modes), or reading experimental output from third-party TFile writers that don't emit the first key correctly.","solutions":["Treat as unreadable corruption: restore from replica/source; there is no caller-side workaround.","If the file came from a third-party writer, regenerate it with the Apache Hadoop TFile.Writer.","Report upstream only if reproducible with files written by this codebase's own Writer (that would be a genuine bug)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  TFile.Reader r = new TFile.Reader(fsdis, fileLength, conf);\n} catch (RuntimeException e) {\n  if (\"Internal error\".equals(e.getMessage())) { /* index invariant broken: file unusable */ }\n  else throw e;\n}","preventionTips":["Only open files produced by the Apache Hadoop TFile.Writer; reject third-party-writer files at ingest.","Atomic publish prevents zeroed/partial index headers.","Keep a source-of-truth copy for regeneration when archives fail this way."],"tags":["tfile","hadoop-common","invariant","index","internal-error"],"backgroundTag":"corrupt-file-detected","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}