-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: malformed go.sum error is ignored #62345
Comments
I enjoy this behavior on |
Yup, Definitely a low-priority bug, just reporting it for awareness |
I agree that |
@bcmills I'd be happy to! |
In 6232dad, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
In 6232dad, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345 Signed-off-by: Adam Cmiel <acmiel1@gmail.com>
In 6232dad, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345 Signed-off-by: Adam Cmiel <acmiel1@gmail.com>
In 6232dad, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
In 6232dad, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
Ended up not being as simple as I expected (simply filling in the missing error checks did not achieve what I needed) Nevertheless, I've sent a somewhat hacky fix 😅 |
Change https://go.dev/cl/527575 mentions this issue: |
In CL 197062, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
In CL 197062, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
In CL 197062, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
In CL 197062, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
In CL 197062, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
In CL 197062, many errors related to go.sum were changed from base.Fatal to error returns. The malformed go.sum error was lost in the process. Currently, when go encounters a malformed go.sum file, go will read the well-formed part of the file and then silently ignore the rest. The motivation behind moving away from base.Fatal was to make the errors show up in -json output. Simply propagating the malformed go.sum error would not achieve this: - For an argument-less 'go mod download -json' with a go>=1.17 module, a malformed go.sum causes an error during LoadModGraph already, before go ever starts downloading modules and printing their JSON. - In other cases, a malformed go.sum would be reported as Error for one of the modules (presumably the one which gets downloaded first) but none of the others. - In either case, 'go mod download' manages to download enough data to succeed on a re-run, making the error look intermittent. Switch the error back to a Fatal one, but give 'go mod tidy' an exception to let it fix broken go.sum files. Fixes golang#62345
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Intentionally break a go.sum file and observe
go mod download
behaviorcreate test project
go.sum (note that line 3 is broken):
go.sum after running
go mod download
:The zip checksums in the broken part of go.sum were removed. I think the reason is that readGoSum returns an error but the callers of readGoSum (first, second) ignore that error. Before returning the error, readGoSum will already have updated the global goSum structure. Effectively, this means that commands which parse go.sum will parse only the non-broken part and ignore the rest.
What did you expect to see?
An error telling me that my go.sum is broken
What did you see instead?
No error, handling only the non-broken part of go.sum
The text was updated successfully, but these errors were encountered: