-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Description
Did you read the migration guide?
- I have read the whole migration guide
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Potential Commit/PR that introduced the regression
No response
NestJS version
11.1.0
Describe the regression
FastifyError with code FST_ERR_CTP_INVALID_MEDIA_TYPE is not being rethrown as an nestjs HttpException.
I have an existing guard that validates content-type to always be application/json and raise a UnsupportedMediaTypeException if not.
But now in nestjs v11, if I make a request with an invalid content-type (say foo), my guard doesnt run and instead I see
FastifyError
code ='FST_ERR_CTP_INVALID_MEDIA_TYPE'
level ='\x1b[31merror\x1b[39m'
message ='Unsupported Media Type: foo'
name ='FastifyError'
statusCode =415
in my custom ExceptionFilter
Minimum reproduction code
https://github.com/yawhide/nestjs-issue-15022
Input code
@Catch(Error)
export class ErrorExceptionFilter extends BaseExceptionFilter {
catch(error: Error, host: ArgumentsHost) {
console.log(error) // error is a FastifyError, not HttpException
}
}Expected behavior
My custom ExceptionFilter should see an HttpException exception instead of a FastifyError when the content-type is invalid.
Other
No response
s-hashimo