SonarSource/sonarqube · error · java.lang.IllegalArgumentException

Unsupported dialect id

Error message

Unsupported dialect id 

What it means

IntegerColumnDef.generateSqlType renders the SQL type for an INTEGER column per dialect (INTEGER for PostgreSQL/H2, INT for MsSql, NUMBER(38,0) for Oracle). Unknown dialect ids throw IllegalArgumentException "Unsupported dialect id ". It signals migrations being executed against an unrecognized database.

Source

Thrown at server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/def/IntegerColumnDef.java:48

@Immutable
public class IntegerColumnDef extends AbstractColumnDef {

  private IntegerColumnDef(Builder builder) {
    super(builder.columnName, builder.isNullable, builder.defaultValue);
  }

  public static Builder newIntegerColumnDefBuilder() {
    return new Builder();
  }

  @Override
  public String generateSqlType(Dialect dialect) {
    return switch (dialect.getId()) {
      case PostgreSql.ID, H2.ID -> "INTEGER";
      case MsSql.ID -> "INT";
      case Oracle.ID -> "NUMBER(38,0)";
      default -> throw new IllegalArgumentException("Unsupported dialect id " + dialect.getId());
    };
  }

  public static class Builder extends AbstractIntegerColumnDefBuilder<Builder> {

    public IntegerColumnDef build() {
      validateColumnName(columnName);
      return new IntegerColumnDef(this);
    }
  }

}

View on GitHub (pinned to 184c821202)

Solutions

  1. Use a supported database (PostgreSQL, SQL Server, Oracle, or H2 for dev); change sonar.jdbc.url accordingly.
  2. Verify dialect resolution so a supported Dialect is selected at startup (check sonar.jdbc.driver and the URL).
  3. In unit tests, pass a Dialect whose id is one of the four supported constants.
  4. Add a case for the new dialect id in IntegerColumnDef if you are extending dialect support.

Example fix

// before
Dialect dialect = new TestDialect("mysql");
columnDef.generateSqlType(dialect); // throws
// after
Dialect dialect = new PostgreSql();
String sql = columnDef.generateSqlType(dialect); // "INTEGER"
Defensive patterns

Strategy: validation

Validate before calling

if (!Set.of(PostgreSql.ID, H2.ID, MsSql.ID, Oracle.ID).contains(dialect.getId())) {
  throw new IllegalArgumentException("Unsupported dialect for integer columns: " + dialect.getId());
}

Try / catch

try {
  String sql = integerColumnDef.generateSqlType(dialect);
} catch (IllegalArgumentException e) {
  throw new IllegalStateException("Use a supported SonarQube database engine", e);
}

Prevention

When it happens

Trigger: Generating DDL for an integer column during a migration when dialect.getId() is not postgresql, h2, mssql or oracle.

Common situations: Configuring an unsupported DB engine (MySQL/MariaDB) for SonarQube; a stub Dialect in tests with an unknown id; corrupted dialect detection producing a bogus id.

Related errors


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