fix(webhook): return generic 500 instead of leaking Supabase error fields#221
Open
anshul23102 wants to merge 1 commit into
Open
fix(webhook): return generic 500 instead of leaking Supabase error fields#221anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
…elds
On INSERT failure (non-duplicate), the webhook handler was serialising the
raw PostgrestError object into the response body, exposing table names,
column names, constraint names, and schema hints via the code, message,
details, and hint fields.
The handler now logs the full error server-side and returns only
{"error":"internal error"} to the caller, keeping all internal database
details out of the HTTP response.
Adds a dedicated test suite for the main webhook route covering the fix,
duplicate-delivery handling, signature rejection, and the success path.
Closes Coder-s-OG-s#218
Contributor
|
@anshul23102 is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Fixes #218.
When the webhook handler failed to INSERT a delivery row (for any error other than a duplicate-key
23505), it returned the rawPostgrestErrorobject in the HTTP response body. This exposed internal database details to any caller that received the 500:code: Postgres error code (e.g.42P01)message: raw Postgres message including table and column namesdetails: key/value details from Postgreshint: Postgres query suggestions revealing constraint and schema infoChanges
src/app/api/webhooks/github/route.tsconsole.errorcall (server-side structured log) and a generic{"error":"internal error"}response body. The full Postgres error is still available in server logs for debugging.src/app/api/webhooks/github/route.test.ts(new file)200 ok=true401400200 duplicate=true500with a generic body that contains nocode,details,hint, or raw Postgres messageTest plan
npx vitest run src/app/api/webhooks/github/route.test.ts- 5/5 passnpx tsc --noEmit- no errorsnpx eslint src/app/api/webhooks/github/route.ts src/app/api/webhooks/github/route.test.ts- no errors