SonarSource/sonarqube · error · IllegalArgumentException

Unsupported frequency:

Error message

Unsupported frequency: 

What it means

AuditHousekeepingFrequencyHelper.getThresholdDate resolves a housekeeping frequency string (e.g. '1_year', '6_months') against the Frequency enum to compute the purge threshold timestamp. If the string does not case-insensitively match any Frequency enum constant name, it throws an IllegalArgumentException with the unsupported value appended.

Source

Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/taskprocessor/AuditHousekeepingFrequencyHelper.java:52

public class AuditHousekeepingFrequencyHelper {
  private final System2 system2;

  public AuditHousekeepingFrequencyHelper(System2 system2) {
    this.system2 = system2;
  }

  public PropertyDto getHouseKeepingFrequency(DbClient dbClient, DbSession dbSession) {
    return Optional.ofNullable(dbClient.propertiesDao()
      .selectGlobalProperty(dbSession, AUDIT_HOUSEKEEPING_FREQUENCY))
      .orElse(defaultAuditHouseKeepingProperty());
  }

  public long getThresholdDate(String frequency) {
    Optional<Frequency> housekeepingFrequency = Arrays.stream(Frequency.values())
      .filter(f -> f.name().equalsIgnoreCase(frequency)).findFirst();
    if (housekeepingFrequency.isEmpty()) {
      throw new IllegalArgumentException("Unsupported frequency: " + frequency);
    }

    return Instant.ofEpochMilli(system2.now())
      .minus(housekeepingFrequency.get().getDays(), ChronoUnit.DAYS)
      .toEpochMilli();
  }

  private static PropertyDto defaultAuditHouseKeepingProperty() {
    PropertyDto property = new PropertyDto();
    property.setKey(AUDIT_HOUSEKEEPING_FREQUENCY);
    property.setValue(DEFAULT_FREQUENCY);
    return property;
  }
}

View on GitHub (pinned to 184c821202)

Solutions

  1. Check the frequency string against allowed values defined by the Frequency enum (e.g. ONLY_1_YEAR equivalents like 1_year, 6_months, 1_month) and correct the property/web call
  2. Fix sonar.dbcleaner.auditHousekeepingFrequency in sonar.properties to a valid value and restart
  3. Validate user/API input against the enum names before calling getThresholdDate

Example fix

// before
helper.getThresholdDate("yearly");
// after
helper.getThresholdDate("1_year");
Defensive patterns

Strategy: validation

Validate before calling

Set<String> allowed = Arrays.stream(Frequency.values())
  .map(Enum::name).collect(Collectors.toSet());
if (!allowed.contains(frequency.toUpperCase(Locale.ROOT))) {
  throw new IllegalArgumentException("Invalid sonar.dbcleaner.auditHousekeepingFrequency: " + frequency);
}

Try / catch

try {
  long threshold = helper.getThresholdDate(frequency);
} catch (IllegalArgumentException e) {
  LOGGER.error("Invalid housekeeping frequency '{}', falling back to default", frequency);
  long threshold = helper.getThresholdDate("1_year");
}

Prevention

When it happens

Trigger: getThresholdDate(frequency) called with a frequency string that matches no Frequency enum name — typically a value read from the sonar.dbcleaner.auditHousekeepingFrequency property or a web request parameter that is misspelled or from an unsupported set.

Common situations: Admin sets an invalid housekeeping frequency in sonar.properties (e.g. 'yearly' instead of '1_year'); API caller passes an unsupported frequency value; upgrade changed the accepted frequency vocabulary.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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