{"record":{"id":"8855d3fe18489295","repo":"SonarSource/sonarqube","slug":"error-during-processing-of-row-s","errorCode":null,"errorMessage":"Error during processing of row: [%s]","messagePattern":"Error during processing of row: \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/SelectImpl.java","lineNumber":48,"sourceCode":"\npublic class SelectImpl extends BaseSqlStatement<Select> implements Select {\n\n  private SelectImpl(PreparedStatement pstmt) {\n    super(pstmt);\n  }\n\n  @Override\n  public <T> List<T> list(Select.RowReader<T> reader) throws SQLException {\n    ResultSet rs = pstmt.executeQuery();\n    Select.Row row = new Select.Row(rs);\n    try {\n      List<T> rows = new ArrayList<>();\n      while (rs.next()) {\n        rows.add(reader.read(row));\n      }\n      return rows;\n    } catch (Exception e) {\n      throw newExceptionWithRowDetails(row, e);\n    } finally {\n      DatabaseUtils.closeQuietly(rs);\n      close();\n    }\n  }\n\n  @Override\n  public <T> T get(Select.RowReader<T> reader) throws SQLException {\n    ResultSet rs = pstmt.executeQuery();\n    Select.Row row = new Select.Row(rs);\n    try {\n      if (rs.next()) {\n        return reader.read(row);\n      }\n      return null;\n    } catch (Exception e) {\n      throw newExceptionWithRowDetails(row, e);\n    } finally {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/SelectImpl.java#L30-L66","documentation":"SelectImpl.list reads all rows of a migration-time SQL query into a list, converting each row via the given RowReader. If reading any row throws (bad type conversion, unexpected null, driver error), the row contents are embedded in 'Error during processing of row: [%s]' and rethrown to pinpoint the offending data. The finally block always closes the ResultSet and the select.","triggerScenarios":"During a db-migration step, rs.next() succeeds but RowReader.read(row) throws — e.g. row.getLong/getString on a column with unexpected type, NULL in a non-null-expecting column, or malformed data left by a previous schema state.","commonSituations":"Upgrading SonarQube across versions where a table contains legacy/corrupt rows; column type drift between schema versions; hand-edited database rows; custom migration steps with wrong reader mapping.","solutions":["Inspect the embedded row data in the message to find the corrupt/unexpected value.","Fix or delete the offending row directly in the database (with a backup) before re-running the migration.","Verify the RowReader mapping matches the actual column types in the SELECT.","Restore from backup if the schema was manually modified."],"exampleFix":"// before\nString name = row.getString(2); // column may be NULL -> exception\n// after\nString name = row.isNull(2) ? null : row.getString(2);","handlingStrategy":"try-catch","validationCode":"-- SQL: inspect rows before migrating\nSELECT * FROM <table> WHERE <mapped_column> IS NULL OR <mapped_column> !~ '^[0-9]+$';","typeGuard":null,"tryCatchPattern":"try {\n  List<MyDto> rows = select().column(...).rows(reader);\n} catch (Exception e) {\n  LOG.error(\"Migration aborted; offending row embedded in message: \" + e.getMessage(), e);\n  throw e; // migration steps must fail loudly\n}","preventionTips":["Back up the database before upgrades","Null-check columns in RowReader implementations for legacy data","Keep RowReader column indices in sync with the SELECT clause","Test migrations on a copy of production data"],"tags":["database","migration","sql","sonarqube","data-mapping"],"backgroundTag":"database-query-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}