opennextjs-aws: Incorrect StatusCode causing monitoring to flag
We’re seeing a ton of error alerts in this function. At closer inspection we see that its simply when a url is referenced without a required querystring parameter. Eg. “url” or “w”. Currently the resulting statusCode is “500” which is why our Monitoring is flagging it.
Shouldn’t this be a 4xx series error code? Likely 400 Bad Request ?
The HTTP 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing).
Examples
- StatusCode: 500
"url" parameter is required - StatusCode: 500
"w" parameter (width) is required
NextJs correctly marks these as “400” errors (not 500)
While OpenNext, marks them as 500
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 27 (15 by maintainers)
I’ll make a PR if you want. ETA tommorow ~ish
You can already use it with
npx -y https://pkg.pr.new/@opennextjs/aws@830 buildIt will probably be reviewed shortly I assume. Until then just use that as your
buildCommand🤦 not enough ☕ this morning. The “don’t use monorepo” pushed me to start a new project outside out repo and I mistakenly used npx create-react-app when I meant to use
npx create-next-app@latestHey @khuezy I’m not sure I know enough about the inner workings of OpenNext to confidently make a change like this. Happy to try though. It’s just that in some ways I’d be guessing. Looking at those lines, it does appear to me that it should just return the status code its given.
Currently its setup to choose between being a failure or success… when perhaps it should simply return the same error that Next gives it. At the very least, it should maybe
buildSuccessResponsefor anything<500errors andbuildFailureResponsefor anything>500?