Skip to content

fix(reports): require a Slack channel id in report recipients - #42850

Merged
EnxDev merged 10 commits into
apache:masterfrom
AryaKetanShCt:fix/slack-recipient-requires-channel-id
Sep 28, 2026
Merged

EnxDev merged 10 commits into
apache:masterfrom
AryaKetanShCt:fix/slack-recipient-requires-channel-id

Conversation

@AryaKetanShCt

@AryaKetanShCt AryaKetanShCt commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

A report or alert saved with a Slack channel name rather than a channel id validates cleanly, runs on schedule, and then never delivers.

ReportRecipientConfigJSONSchema.target is a bare fields.String(), and the only validator on ReportRecipientSchema begins:

if data.get("type") != ReportRecipientType.EMAIL.value:
    return

So email addresses are regex-checked and Slack targets are not checked at all. POST /api/v1/report/ accepts {"type": "SlackV2", "recipient_config_json": {"target": "data-alerts"}} and returns 201.

But SlackV2Notification.send() passes the target straight to files_upload_v2(channel=...), which requires a channel id and answers invalid_arguments for a name. The only signal is an error notification to the report's owner, long after the alert was created, and only if someone reads it.

The UI is unaffected because its picker submits ids from /api/v1/report/slack_channels/. The gap is the API.

This is not theoretical. On one instance 46 recipients had accumulated a channel name, 21 of them on active alerts, the oldest from 2023. Of the 19 distinct names, 5 still matched a live channel, 2 matched archived ones and the rest matched nothing at all, so most could not be repaired even by hand and 15 alerts had to be switched off.

FIX

Validate SlackV2 targets the way Email targets are already validated: every comma, semicolon or whitespace separated part must look like a channel id (^[CGD][A-Z0-9]{6,}$). The error names the offending part and says where to find the id.

The deprecated Slack v1 type is deliberately left alone. v1 sends with files_upload / chat_postMessage, both of which resolve a channel name, and slack.py notes that existing v1 recipients are auto-upgraded to SlackV2 on first send via update_report_schedule_slack_v2. Rejecting names for v1 would break that upgrade path and the v1 contract, and it would fail existing tests that create v1 recipients with names. Since v1 is removed next major, the validation applies only to the type that survives.

The message is deliberately explicit about why, because "invalid channel" reads like a typo when the real cause is that names work with Slack's older chat.postMessage and not with the upload API used for attachments.

TESTING INSTRUCTIONS

Six unit tests in tests/unit_tests/reports/schemas_test.py, following the existing email cases: a single id and multiple ids are accepted; a name, a mixed id-and-name target, and an empty target are rejected; and legacy Slack with a channel name is asserted accepted, pinning the carve-out. The mixed case asserts the message names the bad part and not the good one.

Verified against the schema loaded in a running instance:

type target result
SlackV2 C08CSCSDCSY accepted
SlackV2 data-alerts rejected
SlackV2 C08CSCSDCSY,data-alerts rejected
Slack #general accepted
Slack channel accepted
Email [email protected] accepted

Manually: POST /api/v1/report/ with a SlackV2 recipient whose target is a channel name now returns 400 instead of 201.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot Bot added alert-reports Namespace | Anything related to the Alert & Reports feature change:backend Requires changing the backend labels Aug 6, 2026
@bito-code-review

bito-code-review Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #9bc9d3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 604adaf..6e87dcf
    • superset/reports/schemas.py
    • tests/unit_tests/reports/schemas_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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/reports/schemas.py Resolved
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The new validator in superset/reports/schemas.py enforces Slack channel IDs for both Slack and SlackV2 types, which breaks legacy Slack recipients that rely on channel names. To resolve this, the validation should be restricted to SlackV2 or updated to handle legacy name resolution.

To implement this fix, update the validate_slack_recipients method to only apply the ID-only validation when the type is SlackV2:

    @validates_schema
    def validate_slack_recipients(self, data: dict[str, Any], **kwargs: Any) -> None:
        if data.get("type") != ReportRecipientType.SLACKV2.value:
            return

        target = ((data.get("recipient_config_json") or {}).get("target") or "").strip()
        # ... (rest of the validation logic)

Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well?

superset/reports/schemas.py

@validates_schema
    def validate_slack_recipients(self, data: dict[str, Any], **kwargs: Any) -> None:
        if data.get("type") != ReportRecipientType.SLACKV2.value:
            return

        target = ((data.get("recipient_config_json") or {}).get("target") or "").strip()

@bito-code-review

bito-code-review Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #fa5f18

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6e87dcf..c0801ab
    • superset/reports/schemas.py
    • tests/unit_tests/reports/schemas_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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.21%. Comparing base (f3e3c3f) to head (d5f2450).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42850      +/-   ##
==========================================
- Coverage   81.22%   81.21%   -0.01%     
==========================================
  Files        2968     2968              
  Lines      179399   179343      -56     
  Branches    41601    41558      -43     
==========================================
- Hits       145715   145660      -55     
+ Misses      30974    30973       -1     
  Partials     2710     2710              
Flag Coverage Δ
hive 36.72% <25.00%> (-0.01%) ⬇️
mysql 56.07% <100.00%> (+0.01%) ⬆️
postgres 56.07% <100.00%> (+<0.01%) ⬆️
presto 38.62% <25.00%> (-0.01%) ⬇️
python 85.49% <100.00%> (+<0.01%) ⬆️
sqlite 55.79% <100.00%> (+0.01%) ⬆️
unit 77.79% <100.00%> (+<0.01%) ⬆️

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.

@AryaKetanShCt

Copy link
Copy Markdown
Contributor Author

Addressed the coverage report as well.

Patch coverage was 33% because the flags Codecov aggregates (python, postgres, mysql, …) come from the integration suite, and my tests were unit-only — the unit flag shows <ø>, so none of the new lines were attributed. The validator was tested, just not by anything Codecov was measuring.

Added test_create_report_schedule_slack_v2_requires_channel_id to tests/integration_tests/reports/api_tests.py, which drives the real POST /api/v1/report/ path:

  • a channel name → 400, and the message names the offending value
  • a mixed id,name target → 400, naming only the bad part
  • an empty target → 400
  • two channel ids → 201
  • deprecated Slack v1 with a channel name → 201, pinning the carve-out at the API layer as well as the schema layer

That last case is worth having in the integration suite specifically, since three existing tests in this file already create v1 recipients with {"target": "channel"} and must keep passing.

The unit tests stay as they are — they cover the branch logic cheaply; the integration test covers the wiring and the coverage flags.

@netlify

netlify Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit e78ff93
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a856da3fc18010008ff79ae
😎 Deploy Preview https://deploy-preview-42850--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #9d490b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: c0801ab..9100f62
    • tests/integration_tests/reports/api_tests.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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@AryaKetanShCt
AryaKetanShCt force-pushed the fix/slack-recipient-requires-channel-id branch from 9100f62 to c58965d Compare August 10, 2026 05:25
@AryaKetanShCt

Copy link
Copy Markdown
Contributor Author

hi @eschutho , PTAL and take appropriate action. all checks have passed.

@bito-code-review

bito-code-review Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3f6b28

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 0ab2c4b..64f797e
    • superset/reports/schemas.py
    • tests/integration_tests/reports/api_tests.py
    • tests/unit_tests/reports/schemas_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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@EnxDev

EnxDev commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

EnxDev's Review Agent — #42850 · HEAD e78ff93

comment — the fix is sound and the v1 carve-out is correct and load-bearing, but the "a name never delivers" premise only holds for attachment-bearing sends, so this narrows the API contract further than the description says.

🔴 Functional

  • superset/reports/schemas.py:185 · Medium — The validator rejects a channel name for every SlackV2 recipient, but SlackV2Notification.send() only reaches files_upload_v2 when the content carries a file (slackv2.py:149). With no attachment it falls through to chat_postMessage(channel=...) (slackv2.py:160), which resolves a channel name. Two supported configs land there: report_format: TEXT (commands/report/execute.py:1010) and any alert with ALERTS_ATTACH_REPORTS=False (config.py:834, default True). Those SlackV2 recipients deliver today with a name and now get a 400 on POST/PUT — an API-only break, since the picker always submits ids. Either scope the check to attachment-bearing formats, or keep the hard requirement (defensible: a name silently breaks the moment the format flips to PNG) and say so in the description plus an UPDATING.md entry, since it's a behavior change for existing clients. regression test: POST /api/v1/report/ with report_format: TEXT and a SlackV2 recipient targeting a channel name — pins whichever contract you choose.

🟡 Should-fix

  • superset/reports/schemas.py:209-216 — The message states an absolute ("a name is saved successfully and then never delivers") that is false for the text-only path above, hardcodes a Slack UI navigation path that will drift, and hands translators a six-clause paragraph. Same claim in the docstring at :186. Cut to one sentence: name the offending part, say a channel id is required, point at the dropdown.
  • superset/reports/schemas.py:136 — ^[CGD][A-Z0-9]{6,}$ also rejects user ids (U…/W…), which chat_postMessage accepts as a DM target on the same no-attachment path. The D branch is already speculative — /api/v1/report/slack_channels/ only returns public and private channels — so decide deliberately whether DM targets are in or out, and cover it either way.
  • CI has not run on HEAD. e78ff937 (today's master merge) carries 5 check runs: labeler and the docs preview. The Python suites and the Codecov report are from 64f797e, 9 days back, so "all checks have passed" does not cover the current head or the integration test on it. Worth a push to re-trigger before merge.

🙌 Praise

  • superset/reports/schemas.py:187-193 — The v1 carve-out is right for a reason beyond the one in the comment: NotificationMethod.tsx:688 flips to the v1 free-text field when the channel fetch fails (onError={() => setUseSlackV1(true)}), so blanket validation would have broken the UI's own fallback. Verified too that update_report_schedule_slack_v2 (commands/report/execute.py:184-213) resolves names to ids before writing, so the upgrade path never persists a name as v2 — the carve-out costs nothing.
  • tests/unit_tests/reports/schemas_test.py — The mixed-target test asserting the good id is absent from the message is the right shape for an error-text guarantee.

Reviewed by EnxDev's Review Agent — @EnxDev · HEAD e78ff93.

@rusackas

Copy link
Copy Markdown
Member

Any thoughts on the review comments from @EnxDev? Looks pretty approvable to me otherwise.

@EnxDev EnxDev left a comment

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.

I traced recipient validation into the Slack v1 and SlackV2 delivery paths. Requiring C/G/D IDs only for SlackV2 preserves the legacy channel-name behavior, and the tests cover separators, missing recipients, and malformed IDs. I didn’t find a correctness issue in this pass.

@eschutho eschutho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Posting on Elizabeth's behalf — this is her PR reviewer agent. Forward any pushback to her and she'll loop me back in.

This looks good overall — just a few optional suggestions below, none of which block merge. All line numbers verified against HEAD e78ff937b6.

superset/reports/schemas.py:136,204

The id-shape regex (^[CGD][A-Z0-9]{6,}$) would also accept an uppercase token that isn't a real channel id, e.g. CHANNEL1. It correctly rejects real (lowercase) channel names, so this would only let deliberately-or-typo'd uppercase junk through, and that would still fail at send time.

Totally optional — happy to keep as-is.

superset/reports/schemas.py:198

The target-splitting logic here is reimplemented inline; parse_slack_recipient_targets / recipients_string_to_list already do this for the send path.

Would it be worth reusing the existing helper, so validation tokenization can't drift from delivery tokenization over time?

superset/reports/schemas.py:187-191

Small nit on the comment — it says skipping v1 avoids breaking the v1→v2 upgrade path, but that upgrade command writes recipients via the DAO with already-resolved ids and never goes through this schema. The actual reasons to skip v1 (its send contract + existing v1 tests) are solid; the comment just describes a mechanism that isn't quite what's happening.

WDYT — worth a quick reword?

superset/reports/schemas.py:201,210

The new validator messages are wrapped in _() while the adjacent email-validator messages in the same class aren't, so the two now handle i18n inconsistently. Separately, the longer message hardcodes Slack's current UI wording ("View channel details…"), which could go stale if Slack changes it.

Small suggestion, not required.

@github-actions github-actions Bot added the i18n Namespace | Anything related to localization label Sep 28, 2026
@EnxDev
EnxDev merged commit d130742 into apache:master Sep 28, 2026
72 checks passed
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

villebro pushed a commit that referenced this pull request Sep 30, 2026
Co-authored-by: Enzo Martellucci <[email protected]>
Co-authored-by: Enzo Martellucci <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
(cherry picked from commit d130742)
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 change:backend Requires changing the backend i18n Namespace | Anything related to localization size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants