{"record":{"id":"2e85b50287f91edd","repo":"benbjohnson/litestream","slug":"failed-to-get-object-s-w","errorCode":null,"errorMessage":"failed to get object %s: %w","messagePattern":"failed to get object (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nats/replica_client.go","lineNumber":366,"sourceCode":"\t})\n\n\treturn &ltxFileIterator{files: fileInfos, index: -1}, nil\n}\n\n// OpenLTXFile returns a reader that contains an LTX file at a given TXID range.\nfunc (c *ReplicaClient) OpenLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64) (io.ReadCloser, error) {\n\tif err := c.Init(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\tobjectPath := c.ltxPath(level, minTXID, maxTXID)\n\n\tobjectResult, err := c.objectStore.Get(ctx, objectPath)\n\tif err != nil {\n\t\tif isNotFoundError(err) {\n\t\t\treturn nil, os.ErrNotExist\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to get object %s: %w\", objectPath, err)\n\t}\n\n\t// Record metrics\n\tinternal.OperationTotalCounterVec.WithLabelValues(ReplicaClientType, \"GET\").Inc()\n\t// Note: We can't get the size from NATS object reader directly, so we skip bytes counter\n\n\t// If offset is non-zero then discard the beginning bytes.\n\tif offset > 0 {\n\t\tif _, err := io.CopyN(io.Discard, objectResult, offset); err != nil {\n\t\t\tobjectResult.Close()\n\t\t\treturn nil, fmt.Errorf(\"failed to discard offset bytes: %w\", err)\n\t\t}\n\t}\n\n\t// If size is non-zero then limit the reader to the size.\n\tif size > 0 {\n\t\treturn internal.LimitReadCloser(objectResult, size), nil\n\t}","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/nats/replica_client.go#L348-L384","documentation":"Wraps objectStore.Get failure in the NATS replica client's OpenLTXFile for errors that are not 'not found'. Fires when reading the LTX object at the computed path fails due to connection/server issues; genuine missing objects are instead reported as os.ErrNotExist.","triggerScenarios":"Thrown at nats/replica_client.go:366 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check NATS connectivity and credentials","Verify the object store stream is healthy (nats stream info)","Retry the read operation"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}