-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Bug Description
In my application, I create an instance of a fiber server and fill it with some configurations. After init it I pass the routes and middlewares created.
I have a function for the Error Handler and with any other error when I use context.AllParams() inside it I get the proper return but with this specific error (body limit) the context.route (private field used internally by AllParams) or the context.Route() doesn't return the values, the first one returns nil and gets a panic when called dot params inside the AllParams method. The second one returns a struct with empty values.
All the other methods are getting the proper return (ctx.Path, ctx.Queries, etc).
I guess that the problem is the body limit error is thrown before getting to the routes that fill that variable internally.
How to Reproduce
Steps to reproduce the behavior:
- Create a struct to the application:
type Application struct {
Server *fiber.App
}
var Data *Application- Create a fiber server with the following config:
appinstance.Data = &appinstance.Application{
Server: fiber.New(fiber.Config{
ServerHeader: "Some Header name Here",
ErrorHandler: customErrorHandler,
Prefork: false,
}),
}function to errorHandler:
func customErrorHandler(ctx *fiber.Ctx, err error) error {
allParams := ctx.AllParams()
// panic will happen here getting the params because the internal property route is nil
logging.Log(
&entity.LogDetails{
Message: message,
Method: ctx.Method(),
Reason: err.Error(),
RemoteIP: ctx.IP(),
Request: map[string]interface{}{
"body": string(ctx.BodyRaw()),
"query": ctx.Queries(),
"url_params": ,
},
StatusCode: code,
URLpath: ctx.Path(),
},
"critical",
nil,
)
return nil
}- create a patch route that receives any path param;
- Listen the server and run it;
- make the request sending a file that it's higher than the fiber body limit (the default is 4MB +/- (4 * 1024 * 1024)
Expected Behavior
I expect that the AllParams return the proper value, or return an empty struct at least, because the AllParams don't expect to return an error, but if it can happen would be nice to return it in a v3 of fiber maybe?
Fiber Version
v2.49.2
Code Snippet (optional)
No response
Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my problem prior to opening this one.
- I understand that improperly formatted bug reports may be closed without explanation.

