{"record":{"id":"cb83bd3c0122dccd","repo":"juicedata/juicefs","slug":"failed-to-convert-s-to-s-w","errorCode":null,"errorMessage":"failed to convert %s to %s: %w","messagePattern":"failed to convert (.+?) to (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/load.go","lineNumber":183,"sourceCode":"\tif utils.Exists(nPath) {\n\t\tlogger.Infof(\"plain backup %q already exists, skip conversion\", nPath)\n\t\treturn nPath, nil\n\t}\n\n\tr, err := open(path, key, algo)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer r.Close()\n\n\tw, err := os.Create(nPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create plain backup %s: %w\", nPath, err)\n\t}\n\tdefer w.Close()\n\n\tif _, err = io.Copy(w, r); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to convert %s to %s: %w\", path, nPath, err)\n\t}\n\tlogger.Infof(\"converted backup %q to %q\", path, nPath)\n\treturn nPath, nil\n}\n\nfunc load(ctx *cli.Context) error {\n\tsetup0(ctx, 1, 2)\n\n\tkey, algo := ctx.String(\"encrypt-rsa-key\"), ctx.String(\"encrypt-algo\")\n\tsrc := ctx.Args().Get(1)\n\tvar err error\n\tif ctx.Bool(\"binary\") {\n\t\tif ctx.Bool(\"stat\") {\n\t\t\tsrc = ctx.Args().Get(0)\n\t\t}\n\t\tif src, err = convert(src, key, algo); err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/load.go#L165-L201","documentation":"During conversion, `convert` streams the source backup reader `r` into the newly created plain-backup file with io.Copy. If the copy fails mid-stream, the error is wrapped as `failed to convert <path> to <nPath>: <error>`. Because `r` may be an encrypted/object-store-backed reader, this typically surfaces I/O, permission, or decryption failures partway through the transfer.","triggerScenarios":"io.Copy returns an error reading the source (object storage unreachable, local file read error, decryption failure from a wrong RSA key) or writing to w (disk fills up during the copy).","commonSituations":"Network interruption while pulling the backup from S3/OSS; wrong JFS_RSA_PASSPHRASE or key causing a decrypt error mid-stream; disk quota exceeded during a large backup conversion; source backup truncated/corrupt.","solutions":["Read the wrapped underlying error to identify read vs write side, then fix connectivity or disk space accordingly","Verify the RSA key/passphrase matches the one used to encrypt the backup","Retry the conversion; ensure the source backup completes download first (copy to local disk, then convert)","Validate the backup file integrity (e.g. gzip -t if gzipped) before converting"],"exampleFix":"// before\nJFS_RSA_PASSPHRASE=wrongpass juicefs load meta.sqlite3 enc-backup.json\n// after\nJFS_RSA_PASSPHRASE=correctpass juicefs load meta.sqlite3 enc-backup.json","handlingStrategy":"retry","validationCode":"srcFi, err := os.Stat(srcPath)\nif err != nil { return err }\nfree, _ := diskFree(filepath.Dir(nPath))\nif free < srcFi.Size() { return fmt.Errorf(\"not enough space for conversion\") }","typeGuard":null,"tryCatchPattern":"for i := 0; i < 3; i++ {\n    err := convert(path, nPath)\n    if err == nil { break }\n    if !isTransient(err) { log.Fatalf(\"convert failed: %v\", err); }\n    time.Sleep(time.Duration(i+1) * time.Second)\n}","preventionTips":["Copy remote backups to local disk before converting to avoid mid-stream network failures","Ensure free disk space exceeds the plain backup size","Confirm the RSA key/passphrase before long conversions"],"tags":["io","backup-restore","network"],"backgroundTag":"file-read-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}