SonarSource/sonarqube · error · ServerException

me.getMessage() (invalid offset date-time parameter passed t

Error message

me.getMessage() (invalid offset date-time parameter passed to UsersSearchRequest)

What it means

The UsersSearchRequest constructor parses ISO-8601 offset date-time strings for last-connection filters using DateUtils.parseOffsetDateTime. If parsing fails it throws a MessageException, which is re-wrapped as a ServerException(400, me.getMessage()) carrying the inner message 'invalid offset date-time parameter passed to UsersSearchRequest'.

Source

Thrown at server/sonar-webserver-common/src/main/java/org/sonar/server/common/user/service/UsersSearchRequest.java:59

  private final String groupUuid;
  private final String excludedGroupUuid;

  private UsersSearchRequest(Builder builder) {
    this.page = builder.page;
    this.pageSize = builder.pageSize;
    this.query = builder.query;
    this.deactivated = builder.deactivated;
    this.managed = builder.managed;
    this.externalLogin = builder.externalLogin;
    this.groupUuid = builder.groupUuid;
    this.excludedGroupUuid = builder.excludedGroupUuid;
    try {
      this.lastConnectionDateFrom = Optional.ofNullable(builder.lastConnectionDateFrom).map(DateUtils::parseOffsetDateTime).orElse(null);
      this.lastConnectionDateTo = Optional.ofNullable(builder.lastConnectionDateTo).map(DateUtils::parseOffsetDateTime).orElse(null);
      this.sonarLintLastConnectionDateFrom = Optional.ofNullable(builder.sonarLintLastConnectionDateFrom).map(DateUtils::parseOffsetDateTime).orElse(null);
      this.sonarLintLastConnectionDateTo = Optional.ofNullable(builder.sonarLintLastConnectionDateTo).map(DateUtils::parseOffsetDateTime).orElse(null);
    } catch (MessageException me) {
      throw new ServerException(400, me.getMessage());
    }
  }

  public Integer getPage() {
    return page;
  }

  public Integer getPageSize() {
    return pageSize;
  }

  @CheckForNull
  public String getQuery() {
    return query;
  }

  public boolean isDeactivated() {
    return deactivated;

View on GitHub (pinned to 184c821202)

Solutions

  1. Send a full ISO-8601 offset date-time, e.g. 2024-06-01T00:00:00+0000 or with Z offset.
  2. Validate the parameter format on the client before the call with a strict ISO_OFFSET_DATE_TIME parse.
  3. Omit the parameter entirely if filtering by connection date is not needed.

Example fix

// before
String from = "2024-06-01";
request.setLastConnectionDateFrom(from);
// after
String from = OffsetDateTime.of(2024, 6, 1, 0, 0, 0, 0, ZoneOffset.UTC)
  .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
request.setLastConnectionDateFrom(from);
Defensive patterns

Strategy: validation

Validate before calling

boolean valid = OffsetDateTime.parse(value, DateTimeFormatter.ISO_OFFSET_DATE_TIME) != null; // wrap in try/catch DateTimeParseException

Try / catch

try { searchUsers(from, to); } catch (ServerException e) { if (e.status() == 400 && e.getMessage().contains("offset date-time")) { /* correct format and retry */ } }

Prevention

When it happens

Trigger: Passing a lastConnectionDateFrom/To or sonarLintLastConnectionDateFrom/To parameter to api/users/search that is not a valid offset date-time (e.g. '2024-01-01' with no time/offset, or free-form text).

Common situations: Clients sending plain dates (yyyy-MM-dd) instead of full ISO offset date-times; timestamps from different locales; API clients built before the offset format was enforced.

Related errors


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