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)

Image

While OpenNext, marks them as 500

Image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (15 by maintainers)

Most upvoted comments

Sorry everyone. I would love to dive in to fix this as its a PINA for our monitoring right now. However, I don’t really have the time atm to troubshoot the contrib dev environment. If anyone else feels like they have time, we appreciate it. Otherwise completely understand.

I’ll make a PR if you want. ETA tommorow ~ish

What does the timeline look like to get it to a build?

You can already use it with npx -y https://pkg.pr.new/@opennextjs/aws@830 build

It 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@latest

Hey @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 buildSuccessResponse for anything <500 errors and buildFailureResponse for anything >500?