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 #1414 botMessage handler in Assistant middleware does not work when other event listeners do not exist #1415

Merged
merged 1 commit into from
Jan 11, 2025

Conversation

seratch
Copy link
Member

@seratch seratch commented Jan 11, 2025

This pull request resolves a bug reported in #1414. I overlooked this pattern because my example apps, used to verify their behavior, always had app.event listeners.

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.

… work when other event listeners do not exist
@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented project:bolt labels Jan 11, 2025
@seratch seratch added this to the 1.45.1 milestone Jan 11, 2025
@seratch seratch self-assigned this Jan 11, 2025
.enterpriseId(context.get("enterprise_id") != null ? context.get("enterprise_id").getAsString() : null)
.teamId(context.get("team_id") != null ? context.get("team_id").getAsString() : null)
.channelId(context.get("channel_id") != null ? context.get("channel_id").getAsString() : null)
// enterprise_id here can be a null value
Copy link
Member Author

Choose a reason for hiding this comment

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

while testing this change, I found that this pattern could result in a runtime error. I don't think this was the same when we released this feature but the error needs to be eliminated anyway

@@ -134,9 +137,12 @@ public EventRequest(
// message events (user replies)
this.getContext().setAssistantThreadEvent(true);
this.getContext().setChannelId(event.get("channel").getAsString());
if (event.get("thread_ts") != null) {
if (event.get("thread_ts") != null
&& !event.get("thread_ts").isJsonNull()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this property cannot be null but for safety...


public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<>();
map.put("enterpriseId", this.enterpriseId);
map.put("teamId", this.teamId);
map.put("channelId", this.channelId);
map.put("thread_entry_point", this.threadEntryPoint);
Copy link
Member Author

Choose a reason for hiding this comment

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

This property was added recently

Copy link

codecov bot commented Jan 11, 2025

Codecov Report

Attention: Patch coverage is 40.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 73.24%. Comparing base (c662295) to head (b4be671).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...m/slack/api/bolt/request/builtin/EventRequest.java 11.11% 0 Missing and 8 partials ⚠️
...ck/api/model/assistant/AssistantThreadContext.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1415      +/-   ##
============================================
- Coverage     73.26%   73.24%   -0.02%     
+ Complexity     4369     4368       -1     
============================================
  Files           474      474              
  Lines         14172    14182      +10     
  Branches       1429     1433       +4     
============================================
+ Hits          10383    10388       +5     
+ Misses         2951     2950       -1     
- Partials        838      844       +6     

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

@seratch seratch merged commit 48df343 into slackapi:main Jan 11, 2025
6 checks passed
@seratch seratch deleted the issue-1414-assistant branch January 11, 2025 00:13
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.

1 participant