{"record":{"id":"23723c4de556c118","repo":"SonarSource/sonarqube","slug":"unsupported-frequency","errorCode":null,"errorMessage":"Unsupported frequency: ","messagePattern":"Unsupported frequency: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/taskprocessor/AuditHousekeepingFrequencyHelper.java","lineNumber":52,"sourceCode":"\npublic class AuditHousekeepingFrequencyHelper {\n  private final System2 system2;\n\n  public AuditHousekeepingFrequencyHelper(System2 system2) {\n    this.system2 = system2;\n  }\n\n  public PropertyDto getHouseKeepingFrequency(DbClient dbClient, DbSession dbSession) {\n    return Optional.ofNullable(dbClient.propertiesDao()\n      .selectGlobalProperty(dbSession, AUDIT_HOUSEKEEPING_FREQUENCY))\n      .orElse(defaultAuditHouseKeepingProperty());\n  }\n\n  public long getThresholdDate(String frequency) {\n    Optional<Frequency> housekeepingFrequency = Arrays.stream(Frequency.values())\n      .filter(f -> f.name().equalsIgnoreCase(frequency)).findFirst();\n    if (housekeepingFrequency.isEmpty()) {\n      throw new IllegalArgumentException(\"Unsupported frequency: \" + frequency);\n    }\n\n    return Instant.ofEpochMilli(system2.now())\n      .minus(housekeepingFrequency.get().getDays(), ChronoUnit.DAYS)\n      .toEpochMilli();\n  }\n\n  private static PropertyDto defaultAuditHouseKeepingProperty() {\n    PropertyDto property = new PropertyDto();\n    property.setKey(AUDIT_HOUSEKEEPING_FREQUENCY);\n    property.setValue(DEFAULT_FREQUENCY);\n    return property;\n  }\n}\n","sourceCodeStart":34,"sourceCodeEnd":67,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/taskprocessor/AuditHousekeepingFrequencyHelper.java#L34-L67","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Fix sonar.dbcleaner.auditHousekeepingFrequency in sonar.properties to a valid value and restart","Validate user/API input against the enum names before calling getThresholdDate"],"exampleFix":"// before\nhelper.getThresholdDate(\"yearly\");\n// after\nhelper.getThresholdDate(\"1_year\");","handlingStrategy":"validation","validationCode":"Set<String> allowed = Arrays.stream(Frequency.values())\n  .map(Enum::name).collect(Collectors.toSet());\nif (!allowed.contains(frequency.toUpperCase(Locale.ROOT))) {\n  throw new IllegalArgumentException(\"Invalid sonar.dbcleaner.auditHousekeepingFrequency: \" + frequency);\n}","typeGuard":null,"tryCatchPattern":"try {\n  long threshold = helper.getThresholdDate(frequency);\n} catch (IllegalArgumentException e) {\n  LOGGER.error(\"Invalid housekeeping frequency '{}', falling back to default\", frequency);\n  long threshold = helper.getThresholdDate(\"1_year\");\n}","preventionTips":["Only pass Frequency enum names (case-insensitive) from properties or API parameters","Validate the sonar.dbcleaner.auditHousekeepingFrequency value at startup","Document accepted frequency values where admins configure them","Add a config sanity check on node boot to fail fast with a clear message"],"tags":["sonarqube","housekeeping","configuration","frequency"],"backgroundTag":"invalid-config-value","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"}