Skip to content

feat(reports): add webhook option for notifications#36127

Merged
rusackas merged 18 commits into
apache:masterfrom
sjingoi:webhook
Dec 23, 2025
Merged

feat(reports): add webhook option for notifications#36127
rusackas merged 18 commits into
apache:masterfrom
sjingoi:webhook

Conversation

@sjingoi
Copy link
Copy Markdown
Contributor

@sjingoi sjingoi commented Nov 16, 2025

User description

SUMMARY

Added a webhook option for notification method when creating alerts/reports.
Created a new class for webhooks to follow the same pattern as the existing email and slack options

The webhook provides the following information in a request:

  • Name
  • Text
  • Description
  • Content header
  • Dashboard url

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

image

TESTING INSTRUCTIONS

Testing webhook feature:

  1. Set up alerts and reports as outlined in https://superset.apache.org/docs/configuration/alerts-reports
  2. Add a new feature flag "ALERT_REPORT_WEBHOOK": True in superset_config.py
  3. Start superset and go to alerts and reports
  4. Create an alert / report. Set the notification type to webhook.
  5. Enter a webhook url. This can be your own application or anything that accepts webhook such as https://webhook.site/
  6. Wait for the report or alert trigger. When this happens, check to make sure that the application receives all of the relevant data (images, files, headers, etc.)

Testing webhook flag:

  1. Change the feature flag to "ALERT_REPORT_WEBHOOK": False
  2. It should no longer be possible to create new webhook reports
  3. Existing webhook reports will error with a message saying "Attempted to send a Webhook notification but Webhook feature flag is not enabled."

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

CodeAnt-AI Description

Add Webhook notification method for alerts and reports

What Changed

  • Users can choose "Webhook" as a notification method in Alerts & Reports (when the ALERT_REPORT_WEBHOOK feature flag is enabled); the UI shows a required webhook URL input instead of recipient/channel inputs and displays a webhook icon.
  • Backend sends POST requests to the configured webhook target containing report metadata (name, text, description, url) and a header with notification details.
  • Report attachments (CSV, PDF, screenshots) are uploaded as multipart files when present; otherwise the payload is sent as JSON.
  • New configuration and safety checks: a feature flag ALERT_REPORT_WEBHOOK (default off) controls availability, and ALERT_REPORTS_WEBHOOK_HTTPS_ONLY (default true) enforces HTTPS and rejects non-HTTPS webhook URLs.
  • Network and server errors are handled: 5xx and 429 responses trigger retry behavior; 4xx responses are reported as parameter errors; attempting to send when the feature flag is off raises an error.
  • Unit tests added to validate webhook URL parsing, payload structure, file attachments, and HTTPS enforcement.

Impact

✅ Send alerts/reports to webhook endpoints
✅ Include report files and screenshots in webhook requests
✅ Reject non-HTTPS webhook URLs when HTTPS-only config is enabled

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@korbit-ai
Copy link
Copy Markdown

korbit-ai Bot commented Nov 16, 2025

Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment /korbit-review.

Your admin can change your review schedule in the Korbit Console

@sjingoi sjingoi changed the title Webhook feat(alerts and reports): add webhook option for notifications Nov 16, 2025
@sjingoi sjingoi changed the title feat(alerts and reports): add webhook option for notifications feat(reports): add webhook option for notifications Nov 17, 2025
@sadpandajoe sadpandajoe added review:draft review:checkpoint Last PR reviewed during the daily review standup and removed review:checkpoint Last PR reviewed during the daily review standup labels Nov 17, 2025
@sjingoi sjingoi marked this pull request as ready for review November 24, 2025 17:17
@dosubot dosubot Bot added alert-reports Namespace | Anything related to the Alert & Reports feature change:frontend Requires changing the frontend labels Nov 24, 2025
Comment thread superset/config.py Outdated
AlertReports = 'ALERT_REPORTS',
AlertReportTabs = 'ALERT_REPORT_TABS',
AlertReportSlackV2 = 'ALERT_REPORT_SLACK_V2',
AlertReportWebhook = 'ALERT_REPORT_WEBHOOK',
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.

I'm not sure we need this feature flag. I think this won't really break anything for existing users, and only ads new tooling for users.

In fairiness, we should probably open another PR to remove ALERT_REPORT_SLACK_V2 soon and complete that migration. And probably several others 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Someone in the slack chat suggested that I add this to make it similar to how slack notifications are disabled by default and only enabled when a slack API key is provided. I dont mind removing it though since i agree i also dont really see how it breaks anything. Let me know what you think!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Gentle ping @rusackas 😄

@rusackas rusackas added the 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR label Nov 24, 2025
@rusackas rusackas requested review from eschutho and msyavuz November 24, 2025 18:30
@github-actions github-actions Bot added 🎪 80880d8 🚦 building and removed 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Nov 24, 2025
@sfirke
Copy link
Copy Markdown
Member

sfirke commented Dec 2, 2025

This is exciting! I'll just add that I believe this would allow for Superset to send messages in Microsoft Teams, which is something my org would use.

@codeant-ai-for-open-source codeant-ai-for-open-source Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Dec 4, 2025
Comment thread superset-frontend/src/features/alerts/components/RecipientIcon.tsx
Comment thread superset-frontend/src/features/alerts/types.ts
Comment thread superset-frontend/src/features/reports/types.ts
Comment thread superset/config.py
Comment thread superset/reports/notifications/webhook.py Outdated
Comment thread superset/reports/notifications/webhook.py
Comment thread superset/reports/notifications/webhook.py
Comment thread superset/views/base.py
@apache apache deleted a comment from codeant-ai-for-open-source Bot Dec 17, 2025
@rusackas
Copy link
Copy Markdown
Member

I think we've resolved all but one bot-discovered issue here, and we just have some pre-commit/CI issues to tend to.

If you can patch this up a bit (or allow me to write to your fork/branch/pr) I think we can get this one through!

@apache apache deleted a comment from codeant-ai-for-open-source Bot Dec 17, 2025
@sjingoi
Copy link
Copy Markdown
Contributor Author

sjingoi commented Dec 17, 2025

@rusackas Ill patch it up tonight with my teammate. Thanks for the feedback its been really helpful :D

AlwaysIngame and others added 3 commits December 17, 2025 19:04
Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
except (json.JSONDecodeError, KeyError, TypeError) as ex:
raise NotificationParamException("Webhook URL is required") from ex

def _get_req_payload(self) -> dict[str, Any]:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i just want to highlight that the selection of this structure for the json payload was kind of arbitrary. Is there any particular structure we want to format this in or are we good with the way it is?

@apache apache deleted a comment from codeant-ai-for-open-source Bot Dec 18, 2025
@AlwaysIngame
Copy link
Copy Markdown
Contributor

Checks passing, looks like we're good to go?

@rusackas
Copy link
Copy Markdown
Member

This is awesome! Let's merge this sucker! THANK YOU!

@rusackas rusackas merged commit f8cb935 into apache:master Dec 23, 2025
69 checks passed
rusackas pushed a commit that referenced this pull request Apr 17, 2026
…d config

- security.mdx: document API key authentication (PR #37973) — creation via
  Security → API Keys, Bearer token usage, use cases, and security caution
- alerts-reports.mdx: document webhook notifications (PR #36127) — enable
  via ALERT_REPORT_WEBHOOK feature flag, JSON payload format, multipart
  attachments, HTTPS enforcement, and retry behavior
- theming.mdx: update default fonts note (IBM Plex Mono replaces Fira Code
  as default monospace in 6.1); add Theme Validation and Fallback section
  explaining the three-level fallback order and warning log behavior
- configuring-superset.mdx: document HASH_ALGORITHM config key (md5/sha256
  for FedRAMP compliance) and SQLLAB_HISTORY_RETENTION_DAYS (default 30 days,
  None to disable pruning)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
Co-authored-by: Hriday Algh <hridayalgh@gmail.com>
Co-authored-by: Hriday Algh <53922405+AlwaysIngame@users.noreply.github.com>
Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
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:frontend Requires changing the frontend packages 🎪 🔒 showtime-blocked size:L This PR changes 100-499 lines, ignoring generated files size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants