{"record":{"id":"fe8025d3121e973c","repo":"kopia/kopia","slug":"error-copying-results","errorCode":null,"errorMessage":"error copying results","messagePattern":"error copying results","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cache/content_cache.go","lineNumber":83,"sourceCode":"\tc.pc.exclusiveLock(string(blobID))\n\tdefer c.pc.exclusiveUnlock(string(blobID))\n\n\t// check again to see if we perhaps lost the race and the data is now in cache.\n\tif c.pc.getPartial(ctx, BlobIDCacheKey(blobID), offset, length, output) {\n\t\treturn nil\n\t}\n\n\tvar blobData gather.WriteBuffer\n\tdefer blobData.Close()\n\n\tif err := c.fetchBlobInternal(ctx, blobID, &blobData); err != nil {\n\t\treturn err\n\t}\n\n\tif offset == 0 && length == -1 {\n\t\t_, err := blobData.Bytes().WriteTo(output)\n\n\t\treturn errors.Wrap(err, \"error copying results\")\n\t}\n\n\tif offset < 0 || offset+length > int64(blobData.Length()) {\n\t\treturn errors.Errorf(\"invalid (offset=%v,length=%v) for blob %q of size %v\", offset, length, blobID, blobData.Length())\n\t}\n\n\toutput.Reset()\n\n\timpossible.PanicOnError(blobData.AppendSectionTo(output, int(offset), int(length)))\n\n\treturn nil\n}\n\nfunc (c *contentCacheImpl) fetchBlobInternal(ctx context.Context, blobID blob.ID, blobData *gather.WriteBuffer) error {\n\t// read the entire blob\n\tif err := c.st.GetBlob(ctx, blobID, 0, -1, blobData); err != nil {\n\t\tc.pc.reportMissError()\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/internal/cache/content_cache.go#L65-L101","documentation":"getContentFromFullBlob serves a cached full blob: when offset==0 and length==-1 (read everything), it WriteTo's the blob bytes into output. A write failure is wrapped as 'error copying results'. This indicates the output writer failed while consuming cached data.","triggerScenarios":"Calling GetContent with offset 0 and length -1 where the output gather.WriteBuffer/writer errors during WriteTo — e.g. output sink closed, allocation failure, or underlying writer I/O error.","commonSituations":"Downstream consumer closing output early; out-of-memory for very large blobs; custom writer implementations returning errors mid-copy.","solutions":["Inspect the wrapped error for the failing writer cause","Ensure the output buffer/writer passed to GetContent is valid, open, and large enough","Retry GetContent; if reproducible with a specific blob, verify the cached blob is not corrupt","Avoid reusing a closed WriteBuffer across calls"],"exampleFix":"// before\nout, err := newOutput(); if err != nil { return err }\n_, err = cache.GetContent(ctx, out, contentID, 0, -1)\n// after\nout, err := newOutput(); if err != nil { return err }\ndefer func() { if cerr := out.Close(); err == nil { err = cerr } }()\n_, err = cache.GetContent(ctx, out, contentID, 0, -1)","handlingStrategy":"try-catch","validationCode":"if output == nil { return errors.New(\"output buffer must be non-nil\") }","typeGuard":null,"tryCatchPattern":"n, err := cache.GetContent(ctx, output, contentID, 0, -1)\nif err != nil && strings.Contains(err.Error(), \"error copying results\") {\n    return errors.Wrap(err, \"output writer failed while reading cached content\")\n}","preventionTips":["Keep output buffers open until after GetContent returns","Avoid reusing/closing WriteBuffers across calls","Watch memory when reading very large full blobs","Test custom writers against error paths"],"tags":["cache","io","blob"],"backgroundTag":"file-write-failed","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}