{"record":{"id":"bd0dd3fe406b3709","repo":"benbjohnson/litestream","slug":"oss-upload-to-s-w","errorCode":null,"errorMessage":"oss: upload to %s: %w","messagePattern":"oss: upload to (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oss/replica_client.go","lineNumber":267,"sourceCode":"\t// Combine buffered data with rest of reader\n\trc := internal.NewReadCounter(io.MultiReader(&buf, r))\n\n\tfilename := ltx.FormatFilename(minTXID, maxTXID)\n\tkey := c.ltxPath(level, filename)\n\n\t// Store timestamp in OSS metadata for accurate timestamp retrieval\n\tmetadata := map[string]string{\n\t\tMetadataKeyTimestamp: timestamp.Format(time.RFC3339Nano),\n\t}\n\n\t// Use uploader for automatic multipart handling (files >5GB)\n\tresult, err := c.uploader.UploadFrom(ctx, &oss.PutObjectRequest{\n\t\tBucket:   oss.Ptr(c.Bucket),\n\t\tKey:      oss.Ptr(key),\n\t\tMetadata: metadata,\n\t}, rc)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"oss: upload to %s: %w\", key, err)\n\t}\n\n\t// Build file info from the uploaded file\n\tinfo := &ltx.FileInfo{\n\t\tLevel:     level,\n\t\tMinTXID:   minTXID,\n\t\tMaxTXID:   maxTXID,\n\t\tSize:      rc.N(),\n\t\tCreatedAt: timestamp,\n\t}\n\n\tinternal.OperationTotalCounterVec.WithLabelValues(ReplicaClientType, \"PUT\").Inc()\n\tinternal.OperationBytesCounterVec.WithLabelValues(ReplicaClientType, \"PUT\").Add(float64(rc.N()))\n\n\t// ETag indicates successful upload\n\tif result.ETag == nil || *result.ETag == \"\" {\n\t\treturn nil, fmt.Errorf(\"oss: upload failed: no ETag returned\")\n\t}","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/oss/replica_client.go#L249-L285","documentation":"The OSS uploader's UploadFrom call failed while streaming an LTX object to the bucket. This wraps any SDK/network error from the PUT: auth failures, bucket/region mismatch, size limits, or mid-stream connection drops.","triggerScenarios":"WriteLTXFile uploading a newly created LTX file when credentials expire, the network drops mid-upload, the bucket does not exist in the target region, or the RAM policy lacks oss:PutObject.","commonSituations":"Stale AccessKey after rotation; bucket deleted or renamed; regional endpoint misconfigured (defaulting to cn-hangzhou when the bucket lives elsewhere); large compaction files hitting transient timeouts on slow links.","solutions":["Read the wrapped OSS error code: fix AccessDenied by granting oss:PutObject; fix NoSuchBucket by creating the bucket.","Verify region/endpoint matches the bucket (set region explicitly in config instead of relying on the cn-hangzhou default).","Rotate/refresh credentials if the error indicates signature or token expiration (STS tokens expire).","Check network stability/proxy config; Litestream will retry the upload on the next sync."],"exampleFix":"// before\nreplicas:\n  - type: oss\n    bucket: my-bucket\n    path: ltx\n// after\nreplicas:\n  - type: oss\n    bucket: my-bucket\n    region: oss-cn-beijing\n    endpoint: https://oss-cn-beijing.aliyuncs.com\n    path: ltx","handlingStrategy":"retry","validationCode":"if err := client.Init(ctx); err != nil { return err } // fails fast on bad config/creds\nif _, err := client.HeadBucket(ctx); err != nil { return err }","typeGuard":null,"tryCatchPattern":"_, err := client.WriteLTXFile(ctx, key, metadata, r, size)\nif err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) || isRetryable(err) {\n        time.Sleep(backoff); return retry()\n    }\n    return fmt.Errorf(\"upload ltx: %w\", err)\n}","preventionTips":["Use long-lived RAM roles or refresh STS tokens before expiry.","Set explicit region/endpoint matching the bucket.","Ensure stable network for the replication host; uploads of large compaction files need sustained bandwidth."],"tags":["oss","upload","network","storage"],"backgroundTag":"http-request-failed","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"}