Repository navigation
fix: use Long for DND epoch timestamp fields to avoid Integer overflow - #1725
Conversation
Slack returns `next_dnd_end_ts: 9999999999` when a user has no scheduled DND end, which exceeds Integer.MAX_VALUE and fails Gson deserialization with a NumberFormatException. Change nextDndStartTs, nextDndEndTs, and snoozeEndtime from Integer to Long in: - DndEndSnoozeResponse - DndInfoResponse - DndSetSnoozeResponse - DndTeamInfoResponse.DndTeamMemberInfo - DndUpdatedEvent.DndStatus - DndUpdatedUserEvent.DndStatus snoozeRemaining stays Integer since it is a duration, not a timestamp. Fixes #1719 Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1725 +/- ##
============================================
- Coverage 74.07% 74.05% -0.02%
+ Complexity 4829 4827 -2
============================================
Files 490 490
Lines 15033 15033
Branches 1584 1584
============================================
- Hits 11135 11133 -2
- Misses 2971 2972 +1
- Partials 927 928 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
mwbrooks
left a comment
There was a problem hiding this comment.
The fix looks right and the regression tests cover every class that changed. I'd approve once we've settled how the type change below ships.
| private boolean dndEnabled; | ||
| private Integer nextDndStartTs; | ||
| private Integer nextDndEndTs; | ||
| private Long nextDndStartTs; |
There was a problem hiding this comment.
question (blocking): Since these getters and setters change from Integer to Long, apps compiled against 1.56.0 will hit NoSuchMethodError until they rebuild. Could we label this semver:minor and ship it in the next minor with an IMPORTANT release note, the same way #1703 did in v1.56.0?
There was a problem hiding this comment.
Good catch, agreed. Changing the return type changes the method descriptor, so apps compiled against 1.56.0 would hit NoSuchMethodError until they rebuild. It's also a source break for anything like int end = r.getNextDndEndTs();. I've labeled this bug + semver:minor and will hold it for the next minor (1.57.0) instead of 1.56.1. I've also updated the PR description to cover the binary break. Proposed release note, in the same style as #1703:
Important
The DND timestamp fields nextDndStartTs, nextDndEndTs, and snoozeEndtime are now Long instead of Integer (#1725). Slack sends 9999999999 when no DND end is scheduled, which is larger than Integer.MAX_VALUE, so these responses and events failed to parse. This affects DndInfoResponse, DndEndSnoozeResponse, DndSetSnoozeResponse, DndTeamInfoResponse.DndTeamMemberInfo, DndUpdatedEvent.DndStatus, and DndUpdatedUserEvent.DndStatus. Code that stores these values as Integer or int needs to use Long or long, and apps need to be recompiled against this version. snoozeRemaining is still Integer.
Does that wording work for you?
There was a problem hiding this comment.
That wording works for me, it names every affected class and the recompile step. Thanks for updating the description too!
There was a problem hiding this comment.
@mwbrooks which milestone should this go under? The only open 1.x milestone right now is 1.56.1, which is a patch release, so it doesn't seem right for a semver:minor change. Should I create a 1.57.0 milestone, or is there another one you'd like to use?
There was a problem hiding this comment.
mwbrooks
left a comment
There was a problem hiding this comment.
✅ Thanks @AmyScript, the semver:minor label and that IMPORTANT release note cover the type change nicely.
Summary
Fixes #1719.
When a user has no scheduled DND end, Slack returns
"next_dnd_end_ts": 9999999999. That value is larger thanInteger.MAX_VALUE, so Gson fails withJsonSyntaxException(caused byNumberFormatException) when deserializingdnd.*responses anddnd_updated*events.This PR changes the epoch-seconds fields
nextDndStartTs,nextDndEndTs, andsnoozeEndtimefromIntegertoLongin:DndEndSnoozeResponseDndInfoResponseDndSetSnoozeResponseDndTeamInfoResponse.DndTeamMemberInfoDndUpdatedEvent.DndStatusDndUpdatedUserEvent.DndStatussnoozeRemainingstaysIntegerbecause it's a duration in seconds, not a timestamp.Longinstead ofInteger. Code that stores these values asInteger/int(e.g.int end = r.getNextDndEndTs();) or passesIntegerto the setters will no longer compile, and apps compiled against 1.56.x will hitNoSuchMethodErroruntil they are recompiled. Because of this, the PR is labeledsemver:minorand will ship in the next minor with an IMPORTANT release note, like #1703 did in v1.56.0.Out of scope: #1520 (
ChannelCreatedEvent.Channel.created) is a separate overflow of the same kind and isn't touched here.Testing
9999999999for every affected class (DndTest#timestampsLargerThanIntegerMaxValue,DndUpdatedEventTestandDndUpdatedUserEventTest#deserialize_timestampsLargerThanIntegerMaxValue).Longvalues.DndUpdatedEventTest,DndUpdatedUserEventTest, andDndTestall pass.Category
Requirements
Co-Authored-By: Claude svc-devxp-claude@slack-corp.com