dnd.endSnooze/dnd.info fail with NumberFormatException: next_dnd_end_ts is Integer but should be Long (overflow > Integer.MAX_VALUE)

Đang mở Phù hợp với người mới
#1,719 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
api

Hướng nghiên cứu

Đọc các lớp phản hồi được nêu trong issue: DndEndSnoozeResponse, DndInfoResponse và DndSetSnoozeResponse. Đổi các trường giây epoch được liệt kê cùng getter và setter của chúng từ Integer sang Long, sau đó kiểm tra các bài kiểm thử phản hồi hiện có hoặc bổ sung kiểm thử phân tích 9999999999. Công việc hoàn tất khi cả sáu trường đều giữ nguyên các dấu thời gian lớn trong quá trình giải tuần tự.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

dnd.endSnooze (and dnd.info / dnd.setSnooze) fail to deserialize when a DND/snooze timestamp exceeds Integer.MAX_VALUE (2,147,483,647). The response fields are epoch seconds but are typed java.lang.Integer, so any value at or beyond the Year-2038 boundary (2038-01-19T03:14:07Z) overflows. In practice this happens today: when a user has no scheduled DND end, Slack returns "next_dnd_end_ts": 9999999999, which throws.

Affected fields (all epoch seconds, all currently Integer):

  • DndEndSnoozeResponse.nextDndStartTs, DndEndSnoozeResponse.nextDndEndTs
  • DndInfoResponse.nextDndStartTs, DndInfoResponse.nextDndEndTs, DndInfoResponse.snoozeEndtime
  • DndSetSnoozeResponse.snoozeEndtime

These should be Long, consistent with the fix already applied in #1520 ("ChannelCreatedEvent created is Integer, but should be Long").

Reproducible in:
The Slack SDK version
com.slack.api:slack-api-client:1.47.0

(Confirmed still present on main: next_dnd_start_ts and next_dnd_end_ts are declared private Integer ... in slack-api-client/src/main/java/com/slack/api/methods/response/dnd/DndEndSnoozeResponse.java.)

Java Runtime version
openjdk version "21.0.7" 2025-04-15 LTS
OpenJDK Runtime Environment Temurin-21.0.7+6 (build 21.0.7+6-LTS)
OS info
macOS 27.2 (Darwin 27.2.0)
Steps to reproduce:
  1. Call methods.dndEndSnooze(DndEndSnoozeRequest.builder().build()) for a user whose account has no scheduled DND end.
  2. Slack returns a response body containing "next_dnd_end_ts": 9999999999 (value > Integer.MAX_VALUE).
  3. Gson attempts to read it into the Integer nextDndEndTs field and throws.

Minimal illustration of the failing parse:

String body = "{\"ok\":true,\"dnd_enabled\":true,\"next_dnd_start_ts\":9999999999,\"next_dnd_end_ts\":9999999999,\"snooze_enabled\":false}";
GsonFactory.createSnakeCase().fromJson(body, DndEndSnoozeResponse.class); // throws
Expected result:

The response deserializes successfully, with the large timestamp preserved (e.g. nextDndEndTs == 9999999999L).

Actual result:
com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Expected an int but was 9999999999 at line 1 column 90 path $.next_dnd_end_ts
    at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:267)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:516)
    at com.slack.api.methods.impl.MethodsClientImpl.parseJsonResponseAndRunListeners(MethodsClientImpl.java:4078)
    at com.slack.api.methods.impl.MethodsClientImpl.dndEndSnooze(MethodsClientImpl.java:2338)
    ...
Caused by: java.lang.NumberFormatException: Expected an int but was 9999999999 at line 1 column 90 path $.next_dnd_end_ts
    at com.google.gson.stream.JsonReader.nextInt(JsonReader.java:1304)
Suggested fix

Change the affected epoch-seconds fields from Integer to Long (and their getters/setters), matching the precedent in #1520. This also future-proofs normal (non-sentinel) DND timestamps, which will all exceed Integer.MAX_VALUE after 2038-01-19.

Ngôn ngữ chính
Java
Star
602
Fork
241
Merge trung bình
18 giờ 33 phút
Pull request đã merge (30 ngày)
38

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của slackapi/java-slack-sdk

Tất cả issue của slackapi/java-slack-sdk

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.