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

未關閉 適合新手
#1,719 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java
領域
api

研究方向

閱讀 issue 中提到的回應類別:DndEndSnoozeResponse、DndInfoResponse 和 DndSetSnoozeResponse。將列出的 epoch 秒欄位及其 getter 和 setter 從 Integer 改為 Long,然後檢查現有回應測試,或新增解析 9999999999 的測試。完成標準是六個欄位在反序列化期間都能保留較大的時間戳。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Java
星號
602
分支
241
平均合併
18 小時 33 分鐘
30 天內合併 PR
38

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

slackapi/java-slack-sdk 的其他 Issue

查看 slackapi/java-slack-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。