Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: misleading documentation about the error returned by MaxBytesReader #53764

Closed
gazerro opened this issue Jul 9, 2022 · 3 comments
Closed
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@gazerro
Copy link
Contributor

gazerro commented Jul 9, 2022

In Go 1.19, the MaxBytesReader method returns an error of type *MaxBytesError in case of a Read beyond the limit. But the documentation suggests that the type is MaxBytesError instead.

You have to read the implementation code or deduce it from the Error method that uses a pointer receiver.

@mknyszek mknyszek added this to the Backlog milestone Jul 11, 2022
@mknyszek
Copy link
Contributor

CC @neild

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 11, 2022
@gazerro
Copy link
Contributor Author

gazerro commented Jul 11, 2022

The correct form should be returns an error of type *MaxBytesError for a Read beyond the limit instead of returns a MaxBytesError for a Read beyond the limit.

@gopherbot
Copy link

Change https://go.dev/cl/416914 mentions this issue: net/http: clarify that MaxBytesReader returns *MaxBytesError

jproberts pushed a commit to jproberts/go that referenced this issue Aug 10, 2022
A MaxBytesReader returns a *MaxBytesError when reading beyond
its limit, not a MaxBytesError.

Fixes golang#53764.

Change-Id: Icac3aeac96fd8b172f951241f8f111cda633752c
Reviewed-on: https://go-review.googlesource.com/c/go/+/416914
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Jul 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants