You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Fastify version
5.2.0
Plugin version
8.0.1
Node.js version
22.12.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
15.1.1
Description
Given this plugin registered has follow :
functiononInvalidRequestPayload(
...parameters: Parameters<NonNullable<FastifyCompressOptions['onInvalidRequestPayload']>>){return{statusCode: HTTPStatusCodeEnum.BadRequest,code: 'Invalid Request Payload',name: 'InvalidRequestPayload',error: 'Invalid Request Payload',message: `Payload is not ${parameters[0]} encoded. ${parameters[2].message}`,};}functiononUnsupportedRequestEncoding(
...parameters: Parameters<NonNullable<FastifyCompressOptions['onUnsupportedRequestEncoding']>>){return{statusCode: HTTPStatusCodeEnum.UnsupportedMediaType,code: 'Unsupported Media Type',name: 'UnsupportedMediaType',error: 'Unsupported Media Type',message: `${parameters[0]} encoding is not supported`,};}awaitfastify.register(compressPlugin,{global: true,onInvalidRequestPayload: onInvalidRequestPayload,removeContentLengthHeader: false,onUnsupportedRequestEncoding: onUnsupportedRequestEncoding,});
if a route is registered has follow :
fastifyInstance.withTypeProvider<FastifyZodOpenApiTypeProvider>().route({method: 'POST',url: '/',schema: {body: BODY,response: {[HTTPStatusCodeEnum.OK]: RESPONSE,},},decompress: {// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/promise-function-asynconUnsupportedRequestEncoding: function(encoding,request,reply){// we duplicate this here because our preParsing hook is not triggered in this contextrequest.monitoringScanEvent=MonitoringScanEvent.CreateWithoutTraceId().setName('a');returnonUnsupportedRequestEncoding(encoding,request,reply);},},bodyLimit: 14_680_064,// 14MpreParsing: (request,_reply,_payload,done): void=>{request.monitoringScanEvent=MonitoringScanEvent.CreateWithoutTraceId().setName('a');done();},errorHandler: async(error,request,reply): Promise<void>=>{request.monitoringScanEvent.setStatus('error');request.monitoringScanEvent.mergeWithMessage({error: error.message,});fastifyInstance.errorHandler(error,request,reply);},onResponse: async(request): Promise<void>=>{awaitfastifyInstance.httpClient.getInstance().v1.monitoring.postScanEvent(request.monitoringScanEvent.toObject(),request.monitoringScanEvent.getTraceId(),);},handler: async(request,reply): Promise<ResponseType>=>{constresponse=awaithandler(fastifyInstance,request.body,request.headers,request.monitoringScanEvent,request.log,);returnawaitreply.status(HTTPStatusCodeEnum.OK).send(response);},});
This onInvalidRequestPayload hook provided in the global configuration at plugin registration is not taken into account, instead, the 'default' hook from the plugin is used.
Link to code that reproduces the bug
No response
Expected Behavior
This plugin should merge every options with :
route option first
global option at registration in second
fallback to default plugin option last
The text was updated successfully, but these errors were encountered:
blephy
changed the title
global options are not well merged with route option
global options are not taked into account when route option are defined partially
Jan 2, 2025
blephy
changed the title
global options are not taked into account when route option are defined partially
global options are not taked into account when route options are defined partially
Jan 2, 2025
Prerequisites
Fastify version
5.2.0
Plugin version
8.0.1
Node.js version
22.12.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
15.1.1
Description
Given this plugin registered has follow :
if a route is registered has follow :
This
onInvalidRequestPayload
hook provided in the global configuration at plugin registration is not taken into account, instead, the 'default' hook from the plugin is used.Link to code that reproduces the bug
No response
Expected Behavior
This plugin should merge every options with :
The text was updated successfully, but these errors were encountered: