-
Notifications
You must be signed in to change notification settings - Fork 24
chore: reject invalid requests early #641
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Some suggested prefixes and emojis that may help to write clear, actionable code review comments:
Expand for comment prefix descriptions
|
📦 Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action 🤖 This PR introduced no changes to the javascript bundle 🙌 |
|
@thiskevinwang Can you elaborate a bit on the approach here and explain how we consider a URL to be "invalid"? |
|
@brkalow the approach here is on the naive side: Given a path like... ...I'm decoding it once... ...and if it still contains |
| // catch invalid URIs early | ||
| if (isInvalidURI(pathParts.join('/'))) { | ||
| return { | ||
| notFound: true, | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 Can we expand on the approach / heuristic here for how we determine an invalid URL / why we are doing this? I think that will be a helpful breadcrumb for the future!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually thinking about this more, i'm curious the reasoning behind catching only 404's and returning notFound: true...
dev-portal/src/layouts/sidebar-sidecar/server.ts
Lines 163 to 166 in f8cf9c7
| if (error.status === 404) { | |
| return { notFound: true } | |
| } | |
This class of bad requests cause our Content API to return a Vercel 400, so maybe it'd be simpler to include that in the detected status codes
🔗 Relevant links
Related PR:
🗒️ What
🤷 Why
🛠️ How
📸 Design Screenshots
🧪 Testing
💭 Anything else?