ipfs/kubo · error

%q could not be parsed: %s

Error message

%q could not be parsed: %s

What it means

parsePath in the migrations ipfsfetcher tries to interpret a fetch target as a native IPFS path (via path.NewPath); if that fails it falls back to url.Parse. This error is returned when the string cannot be parsed as a URL at all, meaning the fetchPath is malformed (e.g. contains invalid characters, spaces, or a fundamentally broken URI).

Source

Thrown at repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go:277

	f.addrInfo = peer.AddrInfo{
		ID:    node.Identity,
		Addrs: addrs,
	}

	f.ipfs = ipfs
	f.ipfsStopFunc = stopFunc

	return nil
}

func parsePath(fetchPath string) (path.Path, error) {
	if ipfsPath, err := path.NewPath(fetchPath); err == nil {
		return ipfsPath, nil
	}

	u, err := url.Parse(fetchPath)
	if err != nil {
		return nil, fmt.Errorf("%q could not be parsed: %s", fetchPath, err)
	}

	switch proto := u.Scheme; proto {
	case "ipfs", "ipld", "ipns":
		return path.NewPath(gopath.Join("/", proto, u.Host, u.Path))
	default:
		return nil, fmt.Errorf("%q is not an IPFS path", fetchPath)
	}
}

func readIpfsConfig(repoRoot *string, userConfigFile string) (bootstrap []string, peers []peer.AddrInfo) {
	if repoRoot == nil {
		return
	}

	cfgPath, err := config.Filename(*repoRoot, userConfigFile)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)

View on GitHub (pinned to 329838acdf)

Solutions

  1. Print and inspect the exact fetchPath string; fix or escape invalid URL characters.
  2. Trim whitespace/quotes from the configured Migration.DownloadSources or CID string before use.
  3. Use url.Parse on the string locally to confirm it parses before passing it to the fetcher.

Example fix

// before
fetcher.Fetch("://QmHash")
// after
fetcher.Fetch("https://ipfs.io/ipfs/QmHash")
Defensive patterns

Strategy: validation

Validate before calling

if _, err := url.Parse(fetchPath); err != nil {
    return fmt.Errorf("invalid fetch path %q: %w", fetchPath, err)
}

Try / catch

if err != nil {
    var urlErr *url.Error
    if errors.As(err, &urlErr) { /* bad fetchPath */ }
}

Prevention

When it happens

Trigger: Calling Fetch (or indirectly RunMigration using an IPFS-capable fetcher) with a fetchPath string that is neither a valid IPFS path nor a parseable URL, e.g. "://bad" or a string with control characters.

Common situations: Typing a migration download source or CID reference by hand with typos or stray characters; copying a URL with surrounding whitespace or quotes; programmatically constructing a fetch string with an unescaped character.

Related errors


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