SonarSource/sonarqube · critical · IllegalStateException

Component Export failed after processing %d components succe

Error message

Component Export failed after processing %d components successfully

What it means

ExportComponentsStep.execute() scrolls all components of the project and writes ProjectDump.Component protobufs, assigning sequential refs. Any exception in the streaming/conversion is wrapped in an IllegalStateException that includes the number of components successfully exported so far.

Source

Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java:102

          .setUuidPath(uuidPath)
          .setKey(getString(rs, 4))
          .setName(defaultString(getString(rs, 5)))
          .setDescription(defaultString(getString(rs, 6)))
          .setScope(getString(rs, 7))
          .setQualifier(qualifier)
          .setLanguage(defaultString(getString(rs, 8)))
          .setLongName(defaultString(getString(rs, 9)))
          .setPath(defaultString(getString(rs, 10)))
          .setDeprecatedKey(defaultString(getString(rs, 11)))
          .setProjectUuid(getString(rs, 12))
          .build();
        output.write(component);
        ref++;
        count++;
      }
      LoggerFactory.getLogger(getClass()).debug("{} components exported", count);
    } catch (Exception e) {
      throw new IllegalStateException(format("Component Export failed after processing %d components successfully", count), e);
    }
  }

  private PreparedStatement createSelectStatement(DbSession dbSession) throws SQLException {
    PreparedStatement stmt = dbClient.getMyBatis().newScrollingSelectStatement(dbSession, QUERY);
    try {
      stmt.setString(1, projectHolder.projectDto().getUuid());
      stmt.setBoolean(2, true);
      stmt.setBoolean(3, true);
      return stmt;
    } catch (Exception t) {
      DatabaseUtils.closeQuietly(stmt);
      throw t;
    }
  }

  @Override
  public String getDescription() {

View on GitHub (pinned to 184c821202)

Solutions

  1. Read the wrapped cause; for path/uuid errors inspect the failing component row (the count tells you roughly how far it got).
  2. Verify COMPONENTS table integrity: uuid_path and branch_uuid must reference existing rows.
  3. Fix connectivity/disk issues and re-run the export task.
  4. Repair or remove the inconsistent component row, ideally restoring from backup.
Defensive patterns

Strategy: retry

Validate before calling

// pre-check component tree integrity before export
SELECT c.uuid FROM components c LEFT JOIN components p ON c.component_uuid = p.uuid WHERE c.component_uuid IS NOT NULL AND p.uuid IS NULL;

Try / catch

try {
  exportComponentsStep.execute(context);
} catch (IllegalStateException e) {
  logger.error("Component export failed after {}: {}", parseCount(e.getMessage()), e.getCause(), e);
  throw new JobFailure(e.getCause());
}

Prevention

When it happens

Trigger: SQLException on the components scrolling select; failure converting a ComponentDto (bad uuid/path data); output.write() failing mid-stream.

Common situations: Inconsistent component tree data (broken uuid paths, dangling parents) often from partial upgrades or manual DB changes; DB connection loss during large project export; disk/output failures.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/b3730aac7821ad19. Report an issue: GitHub.