{"record":{"id":"ea0759489ac869e8","repo":"pentaho/pentaho-kettle","slug":"runtimeexception-e","errorCode":null,"errorMessage":"RuntimeException( e )","messagePattern":"RuntimeException\\( e \\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelinput/staxpoi/StaxPoiSheet.java","lineNumber":236,"sourceCode":"      }\n      while ( sheetReader.hasNext() ) {\n        int event = sheetReader.next();\n        if ( event == XMLStreamConstants.START_ELEMENT && sheetReader.getLocalName().equals( TAG_ROW ) ) {\n          String rowIndicator = sheetReader.getAttributeValue( null, \"r\" );\n          currentRow = Integer.parseInt( rowIndicator );\n          if ( currentRow < rownr + 1 ) {\n            continue;\n          }\n          currentRowCells = parseRow();\n          return currentRowCells;\n        }\n        if ( event == XMLStreamConstants.END_ELEMENT && sheetReader.getLocalName().equals( TAG_SHEET_DATA ) ) {\n          // There're no more columns, no need to continue to read\n          break;\n        }\n      }\n    } catch ( Exception e ) {\n      throw new RuntimeException( e );\n    }\n\n    // We've read all document rows, let's update the final count.\n    numRows = currentRow;\n\n    // And, as this was an invalid row to ask for, throw the proper exception!\n    throw new ArrayIndexOutOfBoundsException( rownr );\n  }\n\n  private KCell[] parseRow() throws XMLStreamException {\n    List<StaxPoiCell> cells;\n    if ( isMaxColsNumberDefined() ) {\n      cells = new ArrayList<>( numCols );\n    } else {\n      cells = new ArrayList<>();\n    }\n\n    int undefinedColIndex = 0;","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelinput/staxpoi/StaxPoiSheet.java#L218-L254","documentation":"While streaming the sheet XML in getRow(), any Exception (typically XMLStreamException, IOException after a reader reset, or NumberFormatException on malformed 'r' attributes) is wrapped in a plain RuntimeException. It signals the underlying XLSX part could not be parsed while locating the requested row.","triggerScenarios":"Calling getRow()/cell() on a StaxPoiSheet whose sheetReader fails mid-stream: corrupted xlsx sheet XML, stream closed/reset failure (resetSheetReader), or invalid row numbers in the document.","commonSituations":"Reading truncated or corrupted .xlsx files; files produced by non-Excel tools with missing/invalid row 'r' attributes; random-access getRow() calls that force a reader reset on a broken stream.","solutions":["Validate/repair the xlsx file (open it in Excel or re-export it)","Unwrap the cause (getCause()) to see the underlying XMLStreamException/IOException","Read rows sequentially instead of random access to avoid resetSheetReader()","Catch RuntimeException around getRow and treat the file as unreadable"],"exampleFix":"// before\nKCell[] cells = sheet.getRow(i); // RuntimeException escapes\n// after\ntry {\n  KCell[] cells = sheet.getRow(i);\n} catch (RuntimeException e) {\n  throw new KettleException(\"Failed reading sheet row \" + i, e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"// Pre-validate the file is a readable zip (xlsx) before streaming\ntry (ZipFile zf = new ZipFile(file)) { if (zf.getEntry(\"xl/workbook.xml\") == null) throw new KettleException(\"Not an xlsx\"); }","typeGuard":null,"tryCatchPattern":"try {\n  KCell[] cells = sheet.getRow(rownr);\n} catch (RuntimeException e) {\n  throw new KettleException(\"Sheet read failed\", e.getCause());\n}","preventionTips":["Read rows sequentially; avoid random-access getRow on large sheets","Validate the xlsx file before processing","Prefer ZipSecureFile-hardened POI versions and keep POI updated"],"tags":["runtimeexception","xlsx","xml-parsing"],"backgroundTag":"file-read-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}