juicedata/juicefs · error

failed to convert %s to %s: %w

Error message

failed to convert %s to %s: %w

What it means

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.

Source

Thrown at cmd/load.go:183

	if utils.Exists(nPath) {
		logger.Infof("plain backup %q already exists, skip conversion", nPath)
		return nPath, nil
	}

	r, err := open(path, key, algo)
	if err != nil {
		return "", err
	}
	defer r.Close()

	w, err := os.Create(nPath)
	if err != nil {
		return "", fmt.Errorf("failed to create plain backup %s: %w", nPath, err)
	}
	defer w.Close()

	if _, err = io.Copy(w, r); err != nil {
		return "", fmt.Errorf("failed to convert %s to %s: %w", path, nPath, err)
	}
	logger.Infof("converted backup %q to %q", path, nPath)
	return nPath, nil
}

func load(ctx *cli.Context) error {
	setup0(ctx, 1, 2)

	key, algo := ctx.String("encrypt-rsa-key"), ctx.String("encrypt-algo")
	src := ctx.Args().Get(1)
	var err error
	if ctx.Bool("binary") {
		if ctx.Bool("stat") {
			src = ctx.Args().Get(0)
		}
		if src, err = convert(src, key, algo); err != nil {
			return err
		}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Read the wrapped underlying error to identify read vs write side, then fix connectivity or disk space accordingly
  2. Verify the RSA key/passphrase matches the one used to encrypt the backup
  3. Retry the conversion; ensure the source backup completes download first (copy to local disk, then convert)
  4. Validate the backup file integrity (e.g. gzip -t if gzipped) before converting

Example fix

// before
JFS_RSA_PASSPHRASE=wrongpass juicefs load meta.sqlite3 enc-backup.json
// after
JFS_RSA_PASSPHRASE=correctpass juicefs load meta.sqlite3 enc-backup.json
Defensive patterns

Strategy: retry

Validate before calling

srcFi, err := os.Stat(srcPath)
if err != nil { return err }
free, _ := diskFree(filepath.Dir(nPath))
if free < srcFi.Size() { return fmt.Errorf("not enough space for conversion") }

Try / catch

for i := 0; i < 3; i++ {
    err := convert(path, nPath)
    if err == nil { break }
    if !isTransient(err) { log.Fatalf("convert failed: %v", err); }
    time.Sleep(time.Duration(i+1) * time.Second)
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/cb83bd3c0122dccd. Report an issue: GitHub.