Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1426 IllegalStateException when deserializing message using conversations.history #1429

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

seratch
Copy link
Member

@seratch seratch commented Jan 27, 2025

This pull request resolves #1426

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.

@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented project:slack-api-client project:slack-api-client project:slack-api-model project:slack-api-model labels Jan 27, 2025
@seratch seratch added this to the 1.45.2 milestone Jan 27, 2025
@seratch seratch self-assigned this Jan 27, 2025
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 67.64706% with 11 lines in your changes missing coverage. Please review.

Project coverage is 73.12%. Comparing base (0764bd8) to head (5901635).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../java/com/slack/api/util/json/GsonFileFactory.java 64.51% 4 Missing and 7 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1429      +/-   ##
============================================
- Coverage     73.14%   73.12%   -0.03%     
- Complexity     4375     4386      +11     
============================================
  Files           474      475       +1     
  Lines         14209    14243      +34     
  Branches       1438     1447       +9     
============================================
+ Hits          10393    10415      +22     
- Misses         2969     2973       +4     
- Partials        847      855       +8     

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

Copy link
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.

This seems good 💯

Just for my own understanding, if the groups field is not an array then its content gets removed and if shares.public or shares.private are present then their reply_users fields are not arrays they also get removed?

public class GsonFileFactory implements JsonDeserializer<File>, JsonSerializer<File> {

// This is just a workaround to customize Gson library behavior
// You don't need to edit this class at all
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand this comment, do we still need it?

Copy link
Member Author

Choose a reason for hiding this comment

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

As mentioned below, if you run context.deserialize(jsonObject, File.class); within the deserialize method, it results in StackOverflowError because the same method is associated with the File.class. To let gson mechansim to run a different auto-binding process without stack overflow, I've added this sub class. This is internal hidden class, so you can rename it whenever you want to do so. Also, if you find a better solution to achive the same, please feel free to change this part. It won't be a breaking change because this class and the the code using it are hidden from users.

@seratch seratch force-pushed the issue-1426-gson-error branch from d2a1f9b to 5901635 Compare January 28, 2025 01:25
@seratch seratch merged commit 5593174 into slackapi:main Jan 28, 2025
6 checks passed
@seratch seratch deleted the issue-1426-gson-error branch February 3, 2025 06:31
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 project:slack-api-client project:slack-api-client project:slack-api-model project:slack-api-model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IllegalStateException when deserializing message using conversation.history
2 participants