Skip to content

fix(webhook): return generic 500 instead of leaking Supabase error fields#221

Open
anshul23102 wants to merge 1 commit into
Coder-s-OG-s:mainfrom
anshul23102:fix/218-webhook-error-leak
Open

fix(webhook): return generic 500 instead of leaking Supabase error fields#221
anshul23102 wants to merge 1 commit into
Coder-s-OG-s:mainfrom
anshul23102:fix/218-webhook-error-leak

Conversation

@anshul23102
Copy link
Copy Markdown

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 raw PostgrestError object 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 names
  • details: key/value details from Postgres
  • hint: Postgres query suggestions revealing constraint and schema info

Changes

src/app/api/webhooks/github/route.ts

  • Replaced the raw error serialisation with a console.error call (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)

  • Adds a dedicated test suite for the main webhook receiver covering:
    • Valid new delivery returns 200 ok=true
    • Invalid signature returns 401
    • Missing required headers returns 400
    • Duplicate delivery UUID (23505) returns 200 duplicate=true
    • Non-duplicate INSERT failure returns 500 with a generic body that contains no code, details, hint, or raw Postgres message

Test plan

  • npx vitest run src/app/api/webhooks/github/route.test.ts - 5/5 pass
  • npx tsc --noEmit - no errors
  • npx eslint src/app/api/webhooks/github/route.ts src/app/api/webhooks/github/route.test.ts - no errors

…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
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 25, 2026

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] Webhook INSERT failure leaks raw Supabase error fields (code, details, hint) in the HTTP 500 response body

1 participant