Skip to content
Discussion options

You must be logged in to vote

Ah, welcome to the absolute rite of passage that is webhook signature validation. Almost everyone gets burned by this exact issue the first time.

The culprit is almost certainly this line right here: JSON.stringify(req.body).

The Problem:
If you are using standard middleware like app.use(express.json()) earlier in your code, Express parses the incoming raw string from GitHub and turns it into a JavaScript object (req.body).

When you try to turn it back into a string using JSON.stringify(req.body), the formatting (like spacing, indentation, or property order) changes ever so slightly compared to the exact raw payload GitHub sent. Crypto hashing is incredibly strict—if even a single charact…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by genetbeneberu825-png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug GitHub or a GitHub feature is not working as intended Apps API and Webhooks Discussions related to GitHub's APIs or Webhooks source:ui Discussions created via Community GitHub templates API Discussions around GitHub API platform and docs
2 participants