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

Aperta Adatta ai principianti
#1,719 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
api

Direzione di ricerca

Leggi le classi di risposta indicate nell’issue: DndEndSnoozeResponse, DndInfoResponse e DndSetSnoozeResponse. Cambia da Integer a Long i campi elencati relativi ai secondi dall’epoch e i relativi getter e setter, quindi controlla i test di risposta esistenti oppure aggiungi test per l’analisi di 9999999999. Il lavoro è completato quando tutti e sei i campi conservano i timestamp di grandi dimensioni durante la deserializzazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
602
Fork
241
Merge medio
18h 33m
PR unite (30g)
38

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di slackapi/java-slack-sdk

Tutte le issue di slackapi/java-slack-sdk

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.