SonarSource/sonarqube · error · java.lang.UnsupportedOperationException

Unknown dialect '%s'

Error message

Unknown dialect '%s'

What it means

SmallIntColumnDef.generateSqlType maps dialects to SMALLINT (PostgreSQL, H2, MsSql) or NUMBER(5) (Oracle). Any other dialect id hits the default branch and throws UnsupportedOperationException "Unknown dialect '%s'". Same family as the other column-def dialect checks: migrations only support four database engines.

Source

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

 * Integer that supports signed 16-bit range [-32768..32767].
 */
@Immutable
public class SmallIntColumnDef extends AbstractColumnDef {

  private SmallIntColumnDef(Builder builder) {
    super(builder.columnName, builder.isNullable, null);
  }

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

  @Override
  public String generateSqlType(Dialect dialect) {
    return switch (dialect.getId()) {
      case PostgreSql.ID, H2.ID, MsSql.ID -> "SMALLINT";
      case Oracle.ID -> "NUMBER(5)";
      default -> throw new UnsupportedOperationException(String.format("Unknown dialect '%s'", dialect.getId()));
    };
  }

  public static class Builder {
    @CheckForNull
    private String columnName;
    private boolean isNullable = true;

    public Builder setColumnName(String columnName) {
      this.columnName = validateColumnName(columnName);
      return this;
    }

    public Builder setIsNullable(boolean isNullable) {
      this.isNullable = isNullable;
      return this;
    }

View on GitHub (pinned to 184c821202)

Solutions

  1. Configure a supported database via sonar.jdbc.url (PostgreSQL, SQL Server, Oracle, H2 for dev).
  2. Check why the resolved dialect id is unexpected — verify the JDBC driver and URL mapping to a Dialect implementation.
  3. In tests, use supported dialect constants (PostgreSql.ID, H2.ID, MsSql.ID, Oracle.ID).
  4. Add a switch case for the new dialect if intentionally extending support.

Example fix

// before
sonar.jdbc.url=jdbc:mariadb://db:3306/sonar

// after
sonar.jdbc.url=jdbc:postgresql://db:5432/sonarqube
Defensive patterns

Strategy: validation

Validate before calling

Set<String> ok = Set.of(PostgreSql.ID, H2.ID, MsSql.ID, Oracle.ID);
if (!ok.contains(dialect.getId())) throw new IllegalArgumentException("Unsupported dialect: " + dialect.getId());

Try / catch

try {
  String sql = smallIntColumnDef.generateSqlType(dialect);
} catch (UnsupportedOperationException e) {
  throw new IllegalStateException("Migrations require postgres/mssql/oracle/h2", e);
}

Prevention

When it happens

Trigger: Migration DDL generation for a SMALLINT column with a dialect id outside {postgresql, h2, mssql, oracle}.

Common situations: Running SonarQube against MySQL/MariaDB or another unsupported engine; tests supplying a fake Dialect id; misconfigured JDBC URL leading to a wrong or unknown dialect.

Related errors


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