oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Fiber reuses ctx.pathBuffer across requests, requiring parameter copying

Open HEHOHADA opened this issue 11 months ago • 1 comments

Fiber reuses the pathBuffer for each request and, which can lead to unexpected behavior if parameters are accessed and passed directly using c.Param("%s", key). Instead of using the parameter reference directly, it is necessary to copy its value to avoid potential data corruption or unintended modifications across requests.( as said in fiber docs))

Steps to Reproduce:

Create a Fiber route that accesses a parameter using c.Param("%s", key)( string value). Make multiple concurrent requests with different parameters. Observe that the parameter value might be unexpectedly modified or shared across requests. Expected Behavior: Each request should receive an independent copy of the parameter value to prevent unintended data sharing.

  • The version of oapi-codegen you're using: v2.4.1

  • The version of go you're using: go version go1.23.4 darwin/arm64

  • Spec yml generate: models: true fiber-server: true embedded-spec: true output-options: skip-prune: true compatibility: always-prefix-enum-values: true

HEHOHADA avatar Mar 19 '25 07:03 HEHOHADA

@jamietanna Hello There are any thoughts about it?

HEHOHADA avatar May 20 '25 15:05 HEHOHADA