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 for UnsupportedOperationException in user_change event #407

Merged
merged 1 commit into from
Mar 19, 2020

Conversation

gaurav2493
Copy link
Contributor

@gaurav2493 gaurav2493 commented Mar 19, 2020

Summary

When user_change event is sent, the code breaks with the following exception

java.lang.UnsupportedOperationException: JsonObject

	at com.google.gson.JsonElement.getAsString(JsonElement.java:179)
	at com.slack.api.bolt.middleware.builtin.IgnoringSelfEvents.apply(IgnoringSelfEvents.java:79)

This happens because code expects user to contain string but it contained JSON object

{
    "token": ".....",
    "team_id": ".....",
    "enterprise_id": "....",
    "api_app_id": "....",
    "event": {
        "type": "user_change",
        "user": {
            "id": "....",
            "name": "gaurav",
......
}

fixes #406

@codecov
Copy link

codecov bot commented Mar 19, 2020

Codecov Report

Merging #407 into master will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #407      +/-   ##
============================================
- Coverage     83.91%   83.88%   -0.04%     
- Complexity     2367     2368       +1     
============================================
  Files           249      249              
  Lines          6368     6372       +4     
  Branches        577      578       +1     
============================================
+ Hits           5344     5345       +1     
- Misses          670      674       +4     
+ Partials        354      353       -1
Impacted Files Coverage Δ Complexity Δ
...pi/bolt/middleware/builtin/IgnoringSelfEvents.java 89.58% <100%> (+0.94%) 18 <0> (+1) ⬆️
...pi/methods/metrics/impl/RedisMetricsDatastore.java 87.03% <0%> (-2.47%) 37% <0%> (-1%)
...i/methods/metrics/impl/MemoryMetricsDatastore.java 92.25% <0%> (+0.7%) 42% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aca7d1a...13a245e. Read the comment docs.

@seratch seratch self-assigned this Mar 19, 2020
@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented project:bolt labels Mar 19, 2020
@seratch seratch added this to the 1.0 milestone Mar 19, 2020
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

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

This fix looks great to me. Thank you very much for your contribution!

@seratch seratch merged commit 84dc88c into slackapi:master Mar 19, 2020
seratch added a commit that referenced this pull request Mar 19, 2020
* [bolt] Fix IgnoringSelfEvents to work with all events #407 - thanks @gaurav2493
@gaurav2493 gaurav2493 deleted the user_change_event_fix branch March 20, 2020 03:56
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:bolt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code breaks on receiving "user_change" event
2 participants