GitHub webhook signature verification fails for every request, though the secret is correct.
IntermediateTroubleshootingConcurrency, async, tests, services & containers
Answer
Likely causes → The HMAC is computed over re-serialized JSON (json.dumps(request.json)) instead of the raw body bytes, or the secret has trailing whitespace/newline from the secret store, or comparing against X-Hub-Signature (SHA-1) instead of X-Hub-Signature-256.
Diagnose → Log lengths (never values) of the secret and body; compare computed vs received prefix.
Fix → Use request.get_data() (Flask) or await request.body() (FastAPI) for the HMAC, .strip() the secret, and compare "sha256=" + hexdigest with hmac.compare_digest.
Prevent → Unit test the verifier with a known payload, secret and signature.
More on Concurrency, async, tests, services & containers
`RuntimeError: asyncio.run() cannot be called from a running event loop` in a Jupyter notebook or inside an async framework.Intermediate`RuntimeWarning: coroutine 'fetch' was never awaited` and nothing happens.BeginnerAn asyncio health-checker is no faster than a sequential loop.Advanced`Task was destroyed but it is pending!` at shutdown.Advanced`OSError: [Errno 24] Too many open files` from an asyncio scanner with 20,000 targets.IntermediateA `ThreadPoolExecutor` job finishes "successfully" but half the work is missing, with no errors logged.Intermediate