Skip to content

feat: add generic WebhookChannel notification channel - #3

Merged
oliverm91 merged 5 commits into
mainfrom
feature/additional-notification-channels
Jun 14, 2026
Merged

oliverm91 merged 5 commits into
mainfrom
feature/additional-notification-channels

Conversation

@oliverm91

Copy link
Copy Markdown
Owner

What and why

Adds a generic WebhookChannel notification channel alongside the existing
EmailChannel/FileChannel, so task failures can be POSTed as JSON to any
webhook endpoint (Slack/Discord/Telegram/custom relays, etc.) without coupling
the library to a specific service.

  • New WebhookConfig (url, headers, timeout, optional HMAC-SHA256 secret,
    and extra_payload for service-specific routing keys like a Telegram
    chat_id or Slack channel).
  • New _webhook_internals.py: _WebhookFormatter (JSON payload built from
    _ErrorData, with an overridable _build_payload extension point for
    future service-specific subclasses) and _WebhookHandler (POST via
    urllib.request, optional HMAC body signing, extra_payload merge).
  • Refactored _build_traced_vars_html → _build_traced_vars, now returning
    a plain dict[str, str] ({name: repr(value)}) instead of pre-escaped
    HTML, so non-HTML consumers (webhook JSON, plain-text logfiles) get clean
    data. _HTMLEmailFormatter now does its own HTML escaping of traced_vars.
  • _TaskLogfileFormatter now appends a "Traced vars" section to plain-text
    task logfiles on failure.
  • New manual test (tests/manual_tests/manual_webhook_inspect.py) spins up a
    local HTTP server and verifies the JSON payload and HMAC signature
    end-to-end, without touching the existing manual_pipeline_inspect.py.
  • README updated to document WebhookChannel/WebhookConfig.

Type of change

  • feat — new feature
  • fix — bug fix
  • refactor — no behavior change
  • docs — documentation only
  • test — tests only
  • chore / ci / build

Add WebhookChannel/WebhookConfig: posts a service-agnostic JSON failure
payload via urllib (stdlib only), with optional X-Signature-SHA256 header
when a shared secret is configured. Add manual_webhook_inspect.py as the
webhook counterpart to manual_pipeline_inspect.py.
_build_traced_vars (formerly _build_traced_vars_html) no longer
HTML-escapes results, so _ErrorData.traced_vars / task_context["traced_vars"]
is now a presentation-agnostic dict. _HTMLEmailFormatter does the HTML
escaping when rendering, and the webhook payload now emits structured JSON
instead of an HTML-escaped string.
_TaskLogfileFormatter now appends a "Traced vars:" block listing each
traced local variable's repr, now that traced_vars is a plain dict
rather than a pre-escaped HTML string.
… keys

Lets callers merge static top-level keys (e.g. Telegram chat_id, Slack
channel/username) into the JSON body without subclassing the formatter.
@oliverm91
oliverm91 merged commit 1c65c81 into main Jun 14, 2026
16 checks passed
@oliverm91
oliverm91 deleted the feature/additional-notification-channels branch June 20, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant