{"record":{"id":"8d791524290df8a6","repo":"golang/go","slug":"updating-go-sum-w","errorCode":null,"errorMessage":"updating go.sum: %w","messagePattern":"updating go\\.sum: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/fetch.go","lineNumber":968,"sourceCode":"\tif readonly {\n\t\treturn ErrGoSumDirty\n\t}\n\tif fsys.Replaced(f.goSumFile) {\n\t\tbase.Fatalf(\"go: updates to go.sum needed, but go.sum is part of the overlay specified with -overlay\")\n\t}\n\n\t// Make a best-effort attempt to acquire the side lock, only to exclude\n\t// previous versions of the 'go' command from making simultaneous edits.\n\tif unlock, err := SideLock(ctx); err == nil {\n\t\tdefer unlock()\n\t}\n\n\terr := lockedfile.Transform(f.goSumFile, func(data []byte) ([]byte, error) {\n\t\ttidyGoSum := tidyGoSum(f, data, keep)\n\t\treturn tidyGoSum, nil\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"updating go.sum: %w\", err)\n\t}\n\n\tf.sumState.status = make(map[modSum]modSumStatus)\n\tf.sumState.overwrite = false\n\treturn nil\n}\n\n// TidyGoSum returns a tidy version of the go.sum file.\n// A missing go.sum file is treated as if empty.\nfunc (f *Fetcher) TidyGoSum(keep map[module.Version]bool) (before, after []byte) {\n\tf.mu.Lock()\n\tdefer f.mu.Unlock()\n\tbefore, err := lockedfile.Read(f.goSumFile)\n\tif err != nil && !errors.Is(err, fs.ErrNotExist) {\n\t\tbase.Fatalf(\"reading go.sum: %v\", err)\n\t}\n\tafter = tidyGoSum(f, before, keep)\n\treturn before, after","sourceCodeStart":950,"sourceCodeEnd":986,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/fetch.go#L950-L986","documentation":"Wraps a failure from lockedfile.Transform while rewriting go.sum during TidyGoSum (and friends). Transform applies a function to the file content atomically under the side lock; any underlying error — disk full, permission denied, lockedfile conflict, fsync failure — is wrapped as 'updating go.sum: %w'.","triggerScenarios":"lockedfile.Transform returns err != nil on the go.sum file. Happens during go mod tidy / go get that rewrites go.sum under the SideLock.","commonSituations":"Read-only workspace (CI sandbox), full disk, NFS share with broken locking, GOMODCACHE on a volume without fsync, concurrent go commands racing on the same module dir without the side lock.","solutions":["Check filesystem permissions on the module root and ensure the go.sum file is writable.","Free disk space; inodes as well as bytes.","Avoid running multiple go commands against one module dir concurrently, or ensure GOMODCACHE on a local filesystem.","If on NFS/network FS, move GOMODCACHE to a local path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight check that go.sum is writable and the volume has space.\nfunc goSumWritable(p string) error {\n    fi, err := os.Stat(p)\n    if os.IsNotExist(err) { return nil }\n    if err != nil { return err }\n    if fi.Mode()&0200 == 0 { return fmt.Errorf(\"go.sum not writable\") }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"err := f.TidyGoSum(keep)\nif err != nil {\n    if errors.Is(err, fs.ErrPermission) || errors.Is(err, fs.ErrNoSpace) {\n        // surface to operator; these are environmental\n    }\n    return fmt.Errorf(\"cannot update go.sum: %w\", err)\n}","preventionTips":["Keep the module directory on a writable local filesystem.","Avoid running multiple go commands that mutate go.sum concurrently.","Reserve adequate free space and inodes on the workspace volume."],"tags":["go-sum","io","filesystem","locking"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}