ipfs/kubo · error

not a file node: %q

Error message

not a file node: %q

What it means

ipfsGet retrieves a migration artifact by path from the temp node via the UnixFS Get API and expects the resulting node to be a regular file (files.File). If the node is a directory or other node type, the type assertion fails and this error is returned.

Source

Thrown at cmd/ipfs/kubo/add_migrations.go:156

		err = ipfsGet(ctx, ufs, ipfsPath)
		if err != nil {
			return err
		}
	}

	return nil
}

func ipfsGet(ctx context.Context, ufs coreiface.UnixfsAPI, ipfsPath path.Path) error {
	nd, err := ufs.Get(ctx, ipfsPath)
	if err != nil {
		return err
	}
	defer nd.Close()

	fnd, ok := nd.(files.File)
	if !ok {
		return fmt.Errorf("not a file node: %q", ipfsPath)
	}
	_, err = io.Copy(io.Discard, fnd)
	if err != nil {
		return fmt.Errorf("cannot read migration: %w", err)
	}
	fmt.Printf("Added migration file: %q\n", ipfsPath)
	return nil
}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Point the fetcher at the migration binary file itself, not a containing directory
  2. Verify the downloaded artifact on the temp node (`ipfs ls <path>`); re-fetch if it's a directory
  3. Re-run with --migrate to get fresh artifacts from dist.ipfs.tech
  4. Run migrations with the external fs-repo-migrations tool if the dist layout changed
Defensive patterns

Strategy: type-guard

Validate before calling

st, _ := exec.Command("ipfs", "--config", tmpPath, "ls", migrationPath).Output()
if st != nil && strings.HasPrefix(string(st), "dir/") {
    return errors.New("fetched migration path is a directory")
}

Type guard

fnd, ok := nd.(files.File)
if !ok {
    return fmt.Errorf("not a file node: %T", nd)
}

Prevention

When it happens

Trigger: The path fetched from the migration peer resolves to a non-file UnixFS node — e.g. a directory — so nd.(files.File) does not hold during migration file ingestion.

Common situations: A migration release asset unpacked into a directory instead of a single binary; the fetched path pointing at a wrapping directory; corrupted or mislabeled dist artifacts.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/568c9a51b0815a1a. Report an issue: GitHub.