Repository navigation
fix: answer Slack's URL verification challenge on slack_v0 webhooks - #769
all-hands-bot wants to merge 1 commit into
Conversation
Slack's first delivery to a newly registered webhook URL is a signed url_verification challenge that must be answered with the raw challenge string. The event endpoint treated it as an event: body-derived delivery ID extraction failed on the challenge (400), and even without it the EventResponse JSON was returned instead of the challenge, so URL verification always failed. A slack_v0 webhook now echoes the challenge verbatim, after signature verification and before delivery ID and admission policies only real events satisfy. Co-authored-by: openhands <openhands@all-hands.dev>
|
Warning Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it. |
|
CI This PR adds no migration, so it neither causes nor repairs that collision - happy to renumber in a separate PR if useful. This comment was created by an AI agent (OpenHands) on behalf of the user. |
Description
Slack's Events API requires URL verification: the first delivery to a newly
registered webhook URL is a signed
{"type": "url_verification", "challenge": ...}payload, and Slack expects the raw challenge string back as the responsebody. The event endpoint treated that delivery as an event, so verification
always failed:
event_id_expr, e.g.event.ts), thechallenge payload has no such field and the endpoint answered 400 "Invalid
body delivery ID";
EventResponseJSON instead ofechoing the challenge.
After: a
slack_v0webhook answers a verified challenge withPlainTextResponse(challenge)— after signature verification (the challenge issigned like any other delivery), and before delivery-ID extraction and
admission policies that only real events can satisfy. A missing or non-string
challenge is rejected with 400. Every other scheme and all event processing is
unchanged.
No schema change; nothing to configure beyond the existing
slack_v0scheme(see the schema field description, which now documents the handshake).
Issue Number
None — gap found while testing Slack events against a custom automation
webhook directly (HTTP) rather than through Socket Mode.
Testing
tests/test_event_router.py:text/plain,200), and nothing is recorded in
integration_events;delivery Slack signed;
event.tsand creates a run.tests/test_event_router.pyandtests/test_teams_webhooks.pypass fully;tests/test_providers.pyshows no new failures (its three local failureshere are SQLite-environment artifacts of the test harness, reproduced on
mainwithout this change — raw-SQL UUID binding requires the Postgrestestcontainer).
ruff formatandruff checkclean.Compatibility and risk
slack_v0custom webhooks are affected; built-in sources always usehmac_sha256_hexand never see this path. For aslack_v0webhook whosesender genuinely delivers
{"type": "url_verification", "challenge": ...}signed with the webhook secret, echoing the challenge is exactly the
behavior the scheme's owner defines.
unverified request can never extract a challenge probe.
event_id_expr/admission_expr; thosepolicies are documented as event policies and cannot be applied to the
handshake, which carries no event.
Jev-Fast-Audit
⚡ Jev fast audit · estimates · 0.30s · commit fb483b8
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage: complete supplied coverage; 10/10 hunks, 4/4 files.
All estimates and evidence