Skip to content

fix(model): handle array format for ListRecord.Field message deserial…#1590

Merged
hello-ashleyintech merged 1 commit into
mainfrom
ah-fix-issue-1587
May 15, 2026
Merged

fix(model): handle array format for ListRecord.Field message deserial…#1590
hello-ashleyintech merged 1 commit into
mainfrom
ah-fix-issue-1587

Conversation

@hello-ashleyintech
Copy link
Copy Markdown
Contributor

…ization

Slack's API can return the message field in ListRecord.Field as eithera JSON object or a JSON array. Previously, receiving an array caused an error JsonSyntaxException ("Expected BEGIN_OBJECT but was BEGIN_ARRAY").

Added GsonListRecordFieldFactory to normalize both shapes and not cause regressions on existing expected behavior. The existing getMessage() API continues to return a single Message (first element), and a new getMessages() accessor provides the full list.

Closes #1587

Category (place an x in each of the [ ])

  • bolt (Bolt for Java)
  • bolt-{sub modules} (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.

@hello-ashleyintech hello-ashleyintech requested a review from a team as a code owner May 15, 2026 16:04
@hello-ashleyintech hello-ashleyintech added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented enhancement M-T: A feature request for new functionality semver:minor labels May 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.31%. Comparing base (c636708) to head (0867b00).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...main/java/com/slack/api/model/list/ListRecord.java 57.14% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1590      +/-   ##
============================================
+ Coverage     73.17%   73.31%   +0.13%     
- Complexity     4513     4520       +7     
============================================
  Files           477      478       +1     
  Lines         14291    14298       +7     
  Branches       1488     1490       +2     
============================================
+ Hits          10458    10482      +24     
+ Misses         2940     2929      -11     
+ Partials        893      887       -6     
Flag Coverage Δ
jdk-14 73.31% <57.14%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 🚀 this looks good to me, thanks for including unit tests


public List<Message> getMessages() {
if (messages == null && message != null) {
return Collections.singletonList(message);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweeet 🍬 I like this 💯

public void setMessages(List<Message> messages) {
this.messages = messages;
if (messages != null && !messages.isEmpty()) {
this.message = messages.get(0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure of this, but I think in most cases users will know to use getMessages if they expect multiple messages 🤔

@hello-ashleyintech hello-ashleyintech merged commit 02ec6cd into main May 15, 2026
7 checks passed
@hello-ashleyintech hello-ashleyintech deleted the ah-fix-issue-1587 branch May 15, 2026 16:40
@zimeg zimeg added this to the 1.48.2 milestone May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented enhancement M-T: A feature request for new functionality semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListRecord.Field.message` deserialization fails when Slack returns an array

3 participants