]> Cypherpunks repositories - gostls13.git/commit
cmd/go: make malformed go.sum a fatal error
authorAdam Cmiel <acmiel1@gmail.com>
Tue, 19 Sep 2023 07:22:26 +0000 (07:22 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 27 Sep 2023 14:20:58 +0000 (14:20 +0000)
commita2ff3acb0dbb3d4d3628f359f0e1b091a4f0ee9b
tree10ec14a93202f90a53df003f21e631f1c27a555c
parent33d3625bf8d0aea69c1a64f8da2ff4efe071d7b0
cmd/go: make malformed go.sum a fatal error

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 #62345

Change-Id: I066482b242165bcc6cbba0b2dab64901fad8619f
GitHub-Last-Rev: feae7696d6206cf60b2989e9f431b976d3cddf13
GitHub-Pull-Request: golang/go#62588
Reviewed-on: https://go-review.googlesource.com/c/go/+/527575
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/go/internal/modfetch/fetch.go
src/cmd/go/testdata/script/malformed_gosum_issue62345.txt [new file with mode: 0644]