fix(fastify,express): Respond 400 instead of 500 to requests that cannot be web requests - #9290
Conversation
…nnot become standard Web Requests
🦋 Changeset detectedLatest commit: 01d4695 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-google-signin
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
API Changes Report
Summary
@clerk/expressCurrent version: 2.1.48 Subpath
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
📝 WalkthroughWalkthroughExpress and Fastify middleware now return HTTP 400 when request URLs, targets, methods, or proxy conversions cannot produce Fetch requests. Express can reuse a prebuilt Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Comment |
Description
This PR makes
clerkPlugin(fastify) andclerkMiddleware(express) respond 400 Bad Request instead of 500 to requests that cannot be converted into a fetchRequest. Node's HTTP parser accepts vulnerability-scanner probes such as hostlessGET //targets, targets that parse as credentialed URLs, and TRACE requests, but the middleware's unguardednew URL()/new Request()calls threw on them, surfacing 500s and error-log noise where a bare app answers 404.400 is the status for a request the server cannot process due to a client error such as malformed syntax (RFC 9110 §15.5.1), and it matches what Node and Fastify already return for the same class of input caught at their own layer. The guard also covers the Frontend API proxy branches, and the exported
authenticateRequesthelper is unchanged apart from an optional prebuiltclerkRequestparam that avoids converting twice.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change