Problem
The OpenAPI validation middleware in go/pkg/zen/middleware_openapi_validation.go
calls validator.Validate()
which consumes the request body (r.Body
) without buffering or restoring it. This leaves downstream handlers with an exhausted stream (EOF) when they attempt to read the request body.
Impact
- Downstream handlers cannot access request body content
- API endpoints that need to parse request bodies will fail after validation
- Silent failures where handlers receive empty/EOF body streams
Context
This issue was identified during review of PR #3841 in comment: #3841 (comment)
The validation logic needs to be updated to:
- Buffer the request body before validation
- Restore the body for downstream handlers on both success and error paths
- Ensure proper cleanup and memory management
References