{"record":{"id":"840f1df4d5338988","repo":"SonarSource/sonarqube","slug":"me-getmessage-invalid-offset-date-time-paramete","errorCode":null,"errorMessage":"me.getMessage() (invalid offset date-time parameter passed to UsersSearchRequest)","messagePattern":"me\\.getMessage\\(\\) \\(invalid offset date-time parameter passed to UsersSearchRequest\\)","errorType":"http","errorClass":"ServerException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-common/src/main/java/org/sonar/server/common/user/service/UsersSearchRequest.java","lineNumber":59,"sourceCode":"  private final String groupUuid;\n  private final String excludedGroupUuid;\n\n  private UsersSearchRequest(Builder builder) {\n    this.page = builder.page;\n    this.pageSize = builder.pageSize;\n    this.query = builder.query;\n    this.deactivated = builder.deactivated;\n    this.managed = builder.managed;\n    this.externalLogin = builder.externalLogin;\n    this.groupUuid = builder.groupUuid;\n    this.excludedGroupUuid = builder.excludedGroupUuid;\n    try {\n      this.lastConnectionDateFrom = Optional.ofNullable(builder.lastConnectionDateFrom).map(DateUtils::parseOffsetDateTime).orElse(null);\n      this.lastConnectionDateTo = Optional.ofNullable(builder.lastConnectionDateTo).map(DateUtils::parseOffsetDateTime).orElse(null);\n      this.sonarLintLastConnectionDateFrom = Optional.ofNullable(builder.sonarLintLastConnectionDateFrom).map(DateUtils::parseOffsetDateTime).orElse(null);\n      this.sonarLintLastConnectionDateTo = Optional.ofNullable(builder.sonarLintLastConnectionDateTo).map(DateUtils::parseOffsetDateTime).orElse(null);\n    } catch (MessageException me) {\n      throw new ServerException(400, me.getMessage());\n    }\n  }\n\n  public Integer getPage() {\n    return page;\n  }\n\n  public Integer getPageSize() {\n    return pageSize;\n  }\n\n  @CheckForNull\n  public String getQuery() {\n    return query;\n  }\n\n  public boolean isDeactivated() {\n    return deactivated;","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-common/src/main/java/org/sonar/server/common/user/service/UsersSearchRequest.java#L41-L77","documentation":"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'.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Send a full ISO-8601 offset date-time, e.g. 2024-06-01T00:00:00+0000 or with Z offset.","Validate the parameter format on the client before the call with a strict ISO_OFFSET_DATE_TIME parse.","Omit the parameter entirely if filtering by connection date is not needed."],"exampleFix":"// before\nString from = \"2024-06-01\";\nrequest.setLastConnectionDateFrom(from);\n// after\nString from = OffsetDateTime.of(2024, 6, 1, 0, 0, 0, 0, ZoneOffset.UTC)\n  .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);\nrequest.setLastConnectionDateFrom(from);","handlingStrategy":"validation","validationCode":"boolean valid = OffsetDateTime.parse(value, DateTimeFormatter.ISO_OFFSET_DATE_TIME) != null; // wrap in try/catch DateTimeParseException","typeGuard":null,"tryCatchPattern":"try { searchUsers(from, to); } catch (ServerException e) { if (e.status() == 400 && e.getMessage().contains(\"offset date-time\")) { /* correct format and retry */ } }","preventionTips":["Always send full ISO-8601 offset date-times (yyyy-MM-dd'T'HH:mm:ssZ)","Serialize dates with DateTimeFormatter.ISO_OFFSET_DATE_TIME","Unit-test date serialization against the server contract"],"tags":["http-400","date-parsing","validation","java"],"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-14T11:17:12.474Z"}