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 摘要。