fix(http): reject malformed JSON in webhook adapter#872
Merged
KnorpelSenf merged 2 commits intogrammyjs:mainfrom Feb 26, 2026
Merged
fix(http): reject malformed JSON in webhook adapter#872KnorpelSenf merged 2 commits intogrammyjs:mainfrom
KnorpelSenf merged 2 commits intogrammyjs:mainfrom
Conversation
90126e5 to
7683a56
Compare
18 tasks
Member
|
@all-contributors add @huntharo for bug, code, and test |
Contributor
|
I've put up a pull request to add @huntharo! 🎉 |
Member
|
This was released in 1.40.1. |
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.
Fix uncaught JSON parse exception in
httpwebhook adapterFixes #871
Summary
The Node
http/httpswebhook adapter could throw an uncaught exception when the request body contains malformed JSON.This PR converts that failure mode into a rejected
updatepromise and adds a regression test.Problem
src/convenience/frameworks.ts(httpadapterupdategetter), aroundsrc/convenience/frameworks.ts#L452-L466.JSON.parse(raw)could throw inside the"end"event callback, escaping normal promise rejection flow.Changes
JSON.parse(raw)intry/catchand callreject(err)on parse failures.http should reject malformed JSON bodiesintest/convenience/webhook.test.ts#L163-L200.Validation
deno test --seed=123456 --parallel --allow-import ./test/ test/convenience/webhook.test.tsframework adapters ... http should reject malformed JSON bodiesdeno test --seed=123456 --parallel --allow-import ./test/ test/convenience/webhook.test.ts40 passed,0 failed)Notes