Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't propagate the status received from Discord to GitHub Webhook #1281

Merged
merged 4 commits into from Apr 1, 2024

Conversation

jb3
Copy link
Member

@jb3 jb3 commented Apr 1, 2024

When we received a bad request exception from Discord (which is not actually representative of an error here), we were propagating this back to GitHub.

Instead, we should always return a success request if we have been successful in the proxy attempt, and return the downstream status code as a part of the response body.

This prevents GitHub Webhook Bad Requests being logged to site logs.

Copy link

netlify bot commented Apr 1, 2024

Deploy Preview for pydis-static ready!

Name Link
🔨 Latest commit 3d04acc
🔍 Latest deploy log https://app.netlify.com/sites/pydis-static/deploys/660aaefac93a1e0008d82e8e
😎 Deploy Preview https://deploy-preview-1281--pydis-static.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@coveralls
Copy link

coveralls commented Apr 1, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling 3d04acc on jb3/github-webhook-no-status
into 04672bb on main.

Comment on lines 306 to 307
headers.pop('Connection', None)
headers.pop('Content-Length', None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to do this anymore, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, removed in 346d570


response_body = {
"original_status": response_status,
"data": body.decode("utf-8"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does GH know it has to look in this nested structure now instead of the root?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't -- but it doesn't need to, GitHub stores all response details for us to browse, it doesn't do any processing of this response. I'm going to add a sanity log on our side though to mark when we get a 400 from downstream (but without logging sensitive info).

@jb3 jb3 force-pushed the jb3/github-webhook-no-status branch 2 times, most recently from 229d8fb to 891df20 Compare April 1, 2024 12:00
Copy link
Member

@jchristgit jchristgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great

@jb3 jb3 added area: backend Related to internal functionality and utilities area: API Related to or causes API changes priority: 1 - high High Priority labels Apr 1, 2024
@jb3 jb3 force-pushed the jb3/github-webhook-no-status branch from 891df20 to 3d04acc Compare April 1, 2024 12:56
@jb3 jb3 enabled auto-merge April 1, 2024 12:56
@jb3 jb3 merged commit 5d4e729 into main Apr 1, 2024
11 checks passed
@jb3 jb3 deleted the jb3/github-webhook-no-status branch April 1, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Related to or causes API changes area: backend Related to internal functionality and utilities priority: 1 - high High Priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants