{"record":{"id":"569eeff4c92bab9e","repo":"golangci/golangci-lint","slug":"failed-to-gob-encode-w","errorCode":null,"errorMessage":"failed to gob encode: %w","messagePattern":"failed to gob encode: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cache/cache.go","lineNumber":276,"sourceCode":"\n\th, err := cache.FileHash(f)\n\n\t<-c.ioSem\n\n\tif err != nil {\n\t\treturn [cache.HashSize]byte{}, err\n\t}\n\n\treturn h, nil\n}\n\nfunc (c *Cache) encode(data any) (*bytes.Buffer, error) {\n\tbuf := &bytes.Buffer{}\n\terr := c.sw.TrackStageErr(\"gob\", func() error {\n\t\treturn gob.NewEncoder(buf).Encode(data)\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to gob encode: %w\", err)\n\t}\n\n\treturn buf, nil\n}\n\nfunc (c *Cache) decode(b []byte, data any) error {\n\terr := c.sw.TrackStageErr(\"gob\", func() error {\n\t\treturn gob.NewDecoder(bytes.NewReader(b)).Decode(data)\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to gob decode: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc SetSalt(b *bytes.Buffer) {\n\tcache.SetSalt(b.Bytes())","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/internal/cache/cache.go#L258-L294","documentation":"Wrapping error in Cache.encode, called from Put: gob.NewEncoder(buf).Encode(data) failed while serializing cache data (typically an unencodable value type, unsupported field, or I/O error writing to the buffer). The raw gob error is wrapped with %w so the underlying cause is preserved; the cache write aborts.","triggerScenarios":"Thrown at internal/cache/cache.go:276 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped gob error for the offending type or field","Ensure cached values contain only gob-encodable types (no funcs, channels, or unexported-only fields)","Clear a corrupted cache directory if the data format changed"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}