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
- Replace the timeZone value with a valid IANA zone ID such as 'Europe/Paris' or 'America/New_York'.
- Use ZoneId.getAvailableZoneIds() (java.time) to validate the string before sending the query.
- If only an offset is needed, convert it to a proper zone or drop the parameter and rely on UTC.
- 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
- Always send IANA zone IDs (e.g. 'Europe/Paris'), not offsets like '+02:00'
- Validate zone strings against ZoneId.getAvailableZoneIds() client-side
- Pick zones from a dropdown of valid IDs in UIs instead of free text
- Remember the API ignores invalid zones rather than failing — verify results
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
- Field ' ' is not sortable
- a JVM option can't be empty and must start with '-'. The…
- Address contains invalid character: 0x%02x
- allowAllGroups can only be enabled when Auto-provisioning…
- allowAllGroups cannot be enabled when the GitLab URL is…
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)