I am currently working on fixing an issue in the OpenTelemetry Gin middleware: #6609. However, resolving this properly requires some agreement on the best approach. There are currently three options:

  1. Manually call RemoveAll on the copied context, as done in this PR, which mirrors what echo-contrib does.
  2. Parse the form before calling WithContext. This forces the form to be parsed, which might not be what the user intends.
  3. Reattach the MultipartForm to the original request, without automatic removal or parsing.

There are already some related issues, such as https://github.com/golang/go/issues/58809, https://github.com/golang/go/issues/67713, https://github.com/golang/go/issues/69354, but the recommended approach is still unclear. OpenTelemetry supports many frameworks, and I think some of them have similar issues, not just Gin. Since this issue is closely tied to net/http, an official recommendation would be highly valuable and help us reach a consensus on the best way to fix this.

Comment From: seankhliao

As you've noted, the requirements of the users may differ, I don't think a common recommendation is possible or appropriate. Frameworks should make their own judgement on the split of responsibilities they wish to take over from the user and adjust their approach accordingly.