{"record":{"id":"faa6fbac330a1c6d","repo":"SonarSource/sonarqube","slug":"timezone-cannot-be-parsed-as-a-valid-zone-id","errorCode":null,"errorMessage":"TimeZone '{}' cannot be parsed as a valid zone ID","messagePattern":"TimeZone '(.+?)' cannot be parsed as a valid zone ID","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java","lineNumber":242,"sourceCode":"        .orElseThrow(() -> new IllegalArgumentException(\"Branch with key '\" + branch + \"' does not exist\"));\n      if (!Objects.equals(targetBranch.getUuid(), pullRequest.getMergeBranchUuid())) {\n        throw new IllegalArgumentException(\"Pull request with key '\" + fixedInPullRequest + \"' does not target branch '\" + branch + \"'\");\n      }\n    }\n    return dbClient.issueFixedDao().selectByPullRequest(dbSession, pullRequest.getUuid())\n      .stream()\n      .map(IssueFixedDto::issueKey)\n      .collect(Collectors.toSet());\n  }\n\n  private static Optional<ZoneId> parseTimeZone(@Nullable String timeZone) {\n    if (timeZone == null) {\n      return Optional.empty();\n    }\n    try {\n      return Optional.of(ZoneId.of(timeZone));\n    } catch (DateTimeException e) {\n      LOGGER.warn(\"TimeZone '\" + timeZone + \"' cannot be parsed as a valid zone ID\");\n      return Optional.empty();\n    }\n  }\n\n  private void setCreatedAfterFromDates(IssueQuery.Builder builder, @Nullable Date createdAfter, @Nullable String createdInLast,\n    boolean createdAfterInclusive) {\n    Date actualCreatedAfter = createdAfter;\n    if (createdInLast != null) {\n      actualCreatedAfter = Date.from(\n        OffsetDateTime.now(clock)\n          .minus(Period.parse(\"P\" + createdInLast.toUpperCase(Locale.ENGLISH)))\n          .toInstant());\n    }\n    builder.createdAfter(actualCreatedAfter, createdAfterInclusive);\n  }\n\n  private void setCreatedAfterFromRequest(DbSession dbSession, IssueQuery.Builder builder, SearchRequest request,\n    List<ComponentDto> componentUuids, ZoneId timeZone) {","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java#L224-L260","documentation":"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.","triggerScenarios":"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'.","commonSituations":"API clients passing offsets ('+02:00') instead of IANA zone IDs; UI plugins sending custom zone strings; user-entered timezone values in custom integrations.","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."],"exampleFix":"// before\nissues.search({ timeZone: 'UTC+2' })\n// after\nissues.search({ timeZone: 'Europe/Paris' })","handlingStrategy":"validation","validationCode":"// validate before sending the query parameter\nconst valid = new Set(Intl.supportedValuesOf('timeZone')); // or ZoneId.getAvailableZoneIds() in Java\nif (timeZone && !valid.has(timeZone)) throw new Error('Invalid IANA zone ID: ' + timeZone);","typeGuard":"function isIanaZoneId(s) {\n  if (typeof s !== 'string') return false;\n  try { new Intl.DateTimeFormat('en-US', { timeZone: s }); return true; }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  const zone = ZoneId.of(timeZone);\n} catch (DateTimeException e) {\n  logger.warn(\"TimeZone '\" + timeZone + \"' cannot be parsed as a valid zone ID\");\n  return Optional.empty(); // proceed without timezone\n}","preventionTips":["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"],"tags":["timezone","validation","query-parameter","elasticsearch"],"backgroundTag":"invalid-date-format","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}