0

Starting from few days ago, I've started to receive BadRequestException with Unexpected end of JSON input

This is the trace from NestJS:

mapExternalException(err) {
    switch (true) {
        // SyntaxError is thrown by Express body-parser when given invalid JSON (#422, #430)
        // URIError is thrown by Express when given a path parameter with an invalid percentage
        // encoding, e.g. '%FF' (#8915)
        case err instanceof SyntaxError || err instanceof URIError:
            return new common_1.BadRequestException(err.message); // <--- throws here
        default:
            return err;
    }
}

Application is hosted on AWS and what's weird to me is the url from the request that you can see from sentry log:

{
  data: {}, 
  headers: {
  accept-encoding: gzip, 
  content-length: 1024, 
  content-type: application/json, 
  host: IP_THAT_SEEMS_FROM_AMAZON, 
  user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36, 
  x-amzn-trace-id: Root=1-some-trace-id, 
  x-forwarded-for: SOME_IP, 
  x-forwarded-port: 443, 
  x-forwarded-proto: https
  }, 
  method: POST, 
  query_string: {}, 
  url: https://IP_THAT_SEEMS_FROM_AMAZON/api/report
}

Is it possible that AWS is doing internal requests to /api/report endpoint, and if e.g. HTML is returned application throws Unexpected end of JSON input (because that's usual reason for that error when making requests)?

If anyone is familiar with what's happening, any help would be appreciated!

zhuber
  • 5,364
  • 3
  • 30
  • 63

0 Answers0