fix(reports): paginate Slack recipient picker for large workspaces#41998
fix(reports): paginate Slack recipient picker for large workspaces#41998msyavuz wants to merge 1 commit into
Conversation
The Alerts & Reports SlackV2 recipient picker eagerly enumerated every channel via conversations.list (no Slack search API) and rendered the full list. On workspaces with tens of thousands of channels this hit Slack rate limits (504) and froze the browser. Backend: paginate the /report/slack_channels/ endpoint (page/page_size) and return the full count, so the browser never receives the whole list. The search_string/exact_match params now actually reach the filter. Frontend: switch the picker to AsyncSelect with debounced server-side search (one page at a time) and allowNewOptions so a channel id can be pasted directly, matching the SlackV2 send path. Edit-mode ids resolve via a bounded exact_match lookup. Large workspaces should schedule the existing slack.cache_channels task to keep the channel cache warm.
Code Review Agent Run #85a911Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| page = params.get("page") | ||
| page_size = params.get("page_size") |
There was a problem hiding this comment.
Suggestion: Add explicit type annotations for the newly introduced pagination input variables to satisfy the type-hint requirement. [custom_rule]
Severity Level: Minor 🧹
Why it matters? ⭐
The added local variables page and page_size are unannotated Python variables in newly introduced code. Since they are used as pagination inputs and can be type-hinted, this matches the rule requiring type hints for relevant new or modified Python code.
Rule source 📖
.cursor/rules/dev-standard.mdc (line 28)
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/reports/api.py
**Line:** 686:687
**Comment:**
*Custom Rule: Add explicit type annotations for the newly introduced pagination input variables to satisfy the type-hint requirement.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| count = len(channels) | ||
| if page is not None and page_size is not None: | ||
| start = page * page_size |
There was a problem hiding this comment.
Suggestion: Add type annotations for the new derived pagination variables so their numeric intent is explicit and type-checked. [custom_rule]
Severity Level: Minor 🧹
Why it matters? ⭐
The new local variables count and start are introduced without type annotations in Python code that can be annotated. This is a real violation of the type-hint requirement for relevant variables.
Rule source 📖
.cursor/rules/dev-standard.mdc (line 28)
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/reports/api.py
**Line:** 697:699
**Comment:**
*Custom Rule: Add type annotations for the new derived pagination variables so their numeric intent is explicit and type-checked.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| @@ -36,6 +36,28 @@ def test_slack_channels_success( | |||
| assert rv.status_code == 200 | |||
| data = rv.json | |||
There was a problem hiding this comment.
Suggestion: Add an explicit type annotation for this response payload variable to comply with the type-hint requirement for relevant new variables. [custom_rule]
Severity Level: Minor 🧹
Why it matters? ⭐
The new test introduces a local variable assigned from rv.json without any type annotation. Since this is a newly added Python variable that can reasonably be annotated, it matches the type-hint requirement.
Rule source 📖
.cursor/rules/dev-standard.mdc (line 28)
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tests/unit_tests/reports/api_test.py
**Line:** 37:37
**Comment:**
*Custom Rule: Add an explicit type annotation for this response payload variable to comply with the type-hint requirement for relevant new variables.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #41998 +/- ##
=======================================
Coverage 65.04% 65.04%
=======================================
Files 2742 2742
Lines 153422 153441 +19
Branches 35198 35208 +10
=======================================
+ Hits 99789 99811 +22
+ Misses 51726 51723 -3
Partials 1907 1907
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
SUMMARY
On workspaces with tens of thousands of Slack channels, the Alerts & Reports Slack recipient picker freezes the browser and the backend returns
504. The SlackV2 picker eagerly pulled every channel (conversations.listis paginated and has no search API), so it hit Slack rate limits during enumeration and rendered the entire list at once. The UI'ssearchString/exactMatchparams were also silently ignored (the endpoint readssearch_string/exact_match), so search never reached the server.Backend —
/report/slack_channels/now acceptspage/page_sizeand returns the requested page plus the fullcount, so the browser never receives the whole list.get_channels_with_searchis unchanged (caching andexecute.pyunaffected); slicing happens at the API layer over the warm-cached filtered set.Frontend — the SlackV2 picker moves from an eager
SelecttoAsyncSelect: debounced server-side search, one page at a time (can't freeze), plusallowNewOptionsso a channel ID can be pasted directly and used immediately. This is the guaranteed unblock for huge workspaces — SlackV2 send passes channel-ID strings straight tochat_postMessage, no list membership required. Edit-mode IDs resolve to names via a boundedexact_matchlookup.Large workspaces should schedule the existing
slack.cache_channelsCelery task to keep the cache warm (documented inconfig.py).BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — behavioral fix; no static screenshot captures the freeze. Manual repro/verification steps below.
TESTING INSTRUCTIONS
Automated:
pytest tests/unit_tests/reports/api_test.py(pagination + count) andnpm run test -- NotificationMethod(lazy pagination + direct channel-ID entry).Manual (with
ALERT_REPORT_SLACK_V2on and a Slack bot token configured):C0123456789) — it is accepted directly without the full list loading, and a test send delivers to that channel.slack.cache_channelstask once and confirm the dropdown browses quickly from the warm cache.ADDITIONAL INFORMATION
ALERT_REPORT_SLACK_V2(existing; unchanged)API change is additive/backwards-compatible: the endpoint gains optional
page/page_sizeand acountfield; the previously-ignoredsearch_string/exact_matchnow take effect.