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 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
api

調査の方向性

issue に記載されているレスポンスクラス、DndEndSnoozeResponse、DndInfoResponse、DndSetSnoozeResponse を確認してください。記載されているエポック秒フィールドとその getter および setter の型を Integer から Long に変更し、既存のレスポンステストを確認するか、9999999999 の解析を対象とするテストを追加してください。6 つすべてのフィールドがデシリアライズ時に大きなタイムスタンプを保持できれば完了です。

索引モデルが 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分
マージ済み PR(30日)
38

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

slackapi/java-slack-sdk のほかの issue

slackapi/java-slack-sdk の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。