Skip to content

fix(reports): paginate Slack recipient picker for large workspaces#41998

Open
msyavuz wants to merge 1 commit into
masterfrom
msyavuz/fix/slack-channels-large-workspace
Open

fix(reports): paginate Slack recipient picker for large workspaces#41998
msyavuz wants to merge 1 commit into
masterfrom
msyavuz/fix/slack-channels-large-workspace

Conversation

@msyavuz

@msyavuz msyavuz commented Jul 13, 2026

Copy link
Copy Markdown
Member

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.list is paginated and has no search API), so it hit Slack rate limits during enumeration and rendered the entire list at once. The UI's searchString/exactMatch params were also silently ignored (the endpoint reads search_string/exact_match), so search never reached the server.

Backend/report/slack_channels/ now accepts page/page_size and returns the requested page plus the full count, so the browser never receives the whole list. get_channels_with_search is unchanged (caching and execute.py unaffected); slicing happens at the API layer over the warm-cached filtered set.

Frontend — the SlackV2 picker moves from an eager Select to AsyncSelect: debounced server-side search, one page at a time (can't freeze), plus allowNewOptions so 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 to chat_postMessage, no list membership required. Edit-mode IDs resolve to names via a bounded exact_match lookup.

Large workspaces should schedule the existing slack.cache_channels Celery task to keep the cache warm (documented in config.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) and npm run test -- NotificationMethod (lazy pagination + direct channel-ID entry).

Manual (with ALERT_REPORT_SLACK_V2 on and a Slack bot token configured):

  1. Create an Alert/Report → Notification Method → Slack.
  2. Type part of a channel name — results now load one page at a time via the server instead of pulling every channel.
  3. Paste a raw channel ID (e.g. C0123456789) — it is accepted directly without the full list loading, and a test send delivers to that channel.
  4. Edit an existing Slack report — saved channels render immediately (as IDs, enriched to names once resolved).
  5. For a large workspace, run the slack.cache_channels task once and confirm the dropdown browses quickly from the warm cache.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: ALERT_REPORT_SLACK_V2 (existing; unchanged)
  • Changes UI — Slack recipient picker is now an async, searchable select that accepts pasted channel IDs
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

API change is additive/backwards-compatible: the endpoint gains optional page/page_size and a count field; the previously-ignored search_string/exact_match now take effect.

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.
@dosubot dosubot Bot added alert-reports Namespace | Anything related to the Alert & Reports feature change:backend Requires changing the backend change:frontend Requires changing the frontend labels Jul 13, 2026
@bito-code-review

bito-code-review Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #85a911

Actionable Suggestions - 0
Review Details
  • Files reviewed - 6 · Commit Range: fe3a25a..fe3a25a
    • superset-frontend/src/features/alerts/components/NotificationMethod.test.tsx
    • superset-frontend/src/features/alerts/components/NotificationMethod.tsx
    • superset/config.py
    • superset/reports/api.py
    • superset/reports/schemas.py
    • tests/unit_tests/reports/api_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added the api Related to the REST API label Jul 13, 2026
Comment thread superset/reports/api.py
Comment on lines +686 to +687
page = params.get("page")
page_size = params.get("page_size")

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.

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)

Fix in Cursor Fix in VSCode Claude

(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
👍 | 👎

Comment thread superset/reports/api.py
Comment on lines +697 to +699
count = len(channels)
if page is not None and page_size is not None:
start = page * page_size

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.

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)

Fix in Cursor Fix in VSCode Claude

(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

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.

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)

Fix in Cursor Fix in VSCode Claude

(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

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.14286% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.04%. Comparing base (3c69822) to head (fe3a25a).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
superset/reports/api.py 0.00% 7 Missing ⚠️
.../features/alerts/components/NotificationMethod.tsx 93.87% 3 Missing ⚠️
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           
Flag Coverage Δ
hive 39.06% <0.00%> (-0.01%) ⬇️
javascript 70.34% <93.87%> (+0.01%) ⬆️
mysql 57.96% <0.00%> (-0.01%) ⬇️
postgres 58.02% <0.00%> (-0.01%) ⬇️
presto 41.06% <0.00%> (-0.01%) ⬇️
python 59.40% <0.00%> (-0.01%) ⬇️
sqlite 57.62% <0.00%> (-0.01%) ⬇️
unit 100.00% <ø> (ø)

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alert-reports Namespace | Anything related to the Alert & Reports feature api Related to the REST API change:backend Requires changing the backend change:frontend Requires changing the frontend size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant