Repository navigation
Conversation
A Slack client URL (https://app.slack.com/client/T…/D…) answers a POST with the web app and HTTP 200. post() only checked `status_code < 400`, so it read that as a delivered message: the bot logged "Notified Slack about thread …" while nothing was ever posted. Two checks, because either one alone still leaves a hole: - The URL must start with https://hooks.slack.com/services/. Validated once in __init__ so a misconfigured value is one loud error at startup instead of one line per notification. - A 2xx is not enough. An Incoming Webhook answers with the body "ok"; anything else means the endpoint is not a webhook, however healthy the status code looks. Found in production: the deployed .env held a DM link instead of a webhook, and the bot reported success on every thread. The README and AGENTS.md describe both checks, and the test fixture uses a placeholder Slack client URL instead of a real workspace/DM ID (this repo is public).
crstian19
force-pushed
the
fix/slack-webhook-validation
branch
from
October 20, 2026 08:54
ed4115f to
e19ca22
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
A Slack client URL (
https://app.slack.com/client/T…/D…) answers a POST with the Slack web app and HTTP 200.post()only checkedstatus_code < 400, so it read that as a successful delivery: the bot loggedNotified Slack about thread …without posting anything.It happened in production. The deployed
.envheld a link to a DM instead of a webhook, and the bot reported success on every thread. That false positive sent us looking for the problem in Discord for a while.The fix
Two checks, because either one alone leaves a hole:
https://hooks.slack.com/services/. It is validated once in__init__, so a wrong configuration is one clear error at startup instead of one line per notification.ok; anything else means the endpoint is not a webhook, however healthy the status code looks.The first alone would not be enough, because a deleted webhook on the right domain can answer something other than
ok. The second alone would not be enough either, because any host answeringokwould pass.README (
SLACK_WEBHOOK_URLrow and the Slack section) and AGENTS.md describe both checks. The test fixture uses a placeholder client URL (T00000000/D00000000) rather than a real workspace/DM ID, because this repo is public.Verification
pytestwith Python 3.11 (as in CI and the Dockerfile): 67 passed (61 onmain, 6 new). The new tests cover four non-webhook URL shapes (including the DM link that caused this), a 200 with HTML, and thatOK\ncounts as delivered..lower()or.strip(), and makingenabledignore the validation each fail a named test;okfalls through to the sameFalse.ruff checkandruff format --checkare clean..envhas been corrected. Merging deploys straight to production (deploy.yml: push to main → GHCR →docker compose up). After the deploy, check the container logs forSLACK_WEBHOOK_URL is not an Incoming Webhook…. If it shows up, the server's.envstill holds the DM link and needs fixing by hand.