SonarSource/sonarqube · warning

TimeZone ' ' cannot be parsed as a valid zone ID

Error message

TimeZone '{}' cannot be parsed as a valid zone ID

What it means

IssueQueryFactory parses an optional timeZone string from an issue search query into a ZoneId. When the string is not a valid zone ID (DateTimeException), it logs this warning and returns an empty Optional so the search proceeds without a time-zone filter instead of failing the request.

Solutions

  1. Replace the timeZone value with a valid IANA zone ID such as 'Europe/Paris' or 'America/New_York'.
  2. Use ZoneId.getAvailableZoneIds() (java.time) to validate the string before sending the query.
  3. If only an offset is needed, convert it to a proper zone or drop the parameter and rely on UTC.
  4. Note the query still runs — the warning only means the timezone was ignored.

Example fix

// before
issues.search({ timeZone: 'UTC+2' })
// after
issues.search({ timeZone: 'Europe/Paris' })
Defensive patterns

Strategy: validation

Validate before calling

// validate before sending the query parameter
const valid = new Set(Intl.supportedValuesOf('timeZone')); // or ZoneId.getAvailableZoneIds() in Java
if (timeZone && !valid.has(timeZone)) throw new Error('Invalid IANA zone ID: ' + timeZone);

Type guard

function isIanaZoneId(s) {
  if (typeof s !== 'string') return false;
  try { new Intl.DateTimeFormat('en-US', { timeZone: s }); return true; }
  catch { return false; }
}

Try / catch

try {
  const zone = ZoneId.of(timeZone);
} catch (DateTimeException e) {
  logger.warn("TimeZone '" + timeZone + "' cannot be parsed as a valid zone ID");
  return Optional.empty(); // proceed without timezone
}

Prevention

When it happens

Trigger: timeZone -> parseTimeZone receiving a non-null timeZone parameter that ZoneId.of() cannot parse — e.g. 'UTC+2', 'GMT-05:00' shorthand, or misspelled IDs like 'Europe/Parise'.

Common situations: API clients passing offsets ('+02:00') instead of IANA zone IDs; UI plugins sending custom zone strings; user-entered timezone values in custom integrations.

Related errors


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

Appendix: source

Thrown at server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java:242

        .orElseThrow(() -> new IllegalArgumentException("Branch with key '" + branch + "' does not exist"));
      if (!Objects.equals(targetBranch.getUuid(), pullRequest.getMergeBranchUuid())) {
        throw new IllegalArgumentException("Pull request with key '" + fixedInPullRequest + "' does not target branch '" + branch + "'");
      }
    }
    return dbClient.issueFixedDao().selectByPullRequest(dbSession, pullRequest.getUuid())
      .stream()
      .map(IssueFixedDto::issueKey)
      .collect(Collectors.toSet());
  }

  private static Optional<ZoneId> parseTimeZone(@Nullable String timeZone) {
    if (timeZone == null) {
      return Optional.empty();
    }
    try {
      return Optional.of(ZoneId.of(timeZone));
    } catch (DateTimeException e) {
      LOGGER.warn("TimeZone '" + timeZone + "' cannot be parsed as a valid zone ID");
      return Optional.empty();
    }
  }

  private void setCreatedAfterFromDates(IssueQuery.Builder builder, @Nullable Date createdAfter, @Nullable String createdInLast,
    boolean createdAfterInclusive) {
    Date actualCreatedAfter = createdAfter;
    if (createdInLast != null) {
      actualCreatedAfter = Date.from(
        OffsetDateTime.now(clock)
          .minus(Period.parse("P" + createdInLast.toUpperCase(Locale.ENGLISH)))
          .toInstant());
    }
    builder.createdAfter(actualCreatedAfter, createdAfterInclusive);
  }

  private void setCreatedAfterFromRequest(DbSession dbSession, IssueQuery.Builder builder, SearchRequest request,
    List<ComponentDto> componentUuids, ZoneId timeZone) {

View on GitHub (pinned to 184c821202)