juicedata/juicefs · error

parse %s: %s

Error message

parse %s: %s

What it means

`newEtcdClient` parses the metadata URL with `net/url` after defaulting the scheme to http. If the address cannot be parsed (malformed URL syntax), construction fails with 'parse %s: %s'. This happens before any network connection is made.

Source

Thrown at pkg/meta/tkv_etcd.go:320

	q := u.Query()
	tsinfo.CAFile = q.Get("cacert")
	tsinfo.CertFile = q.Get("cert")
	tsinfo.KeyFile = q.Get("key")
	tsinfo.ServerName = q.Get("server-name")
	tsinfo.InsecureSkipVerify = q.Get("insecure-skip-verify") != ""
	if tsinfo.CAFile != "" || tsinfo.CertFile != "" || tsinfo.KeyFile != "" || tsinfo.ServerName != "" {
		return tsinfo.ClientConfig()
	}
	return nil, nil
}

func newEtcdClient(addr string) (tkvClient, error) {
	if !strings.Contains(addr, "://") {
		addr = "http://" + addr
	}
	u, err := url.Parse(addr)
	if err != nil {
		return nil, fmt.Errorf("parse %s: %s", addr, err)
	}
	passwd, _ := u.User.Password()
	hosts := strings.Split(u.Host, ",")
	for i, h := range hosts {
		h, _, err := net.SplitHostPort(h)
		if err != nil {
			hosts[i] = net.JoinHostPort(h, "2379")
		}
	}
	conf := etcd.Config{
		Endpoints:        hosts,
		Username:         u.User.Username(),
		Password:         passwd,
		AutoSyncInterval: time.Minute,
	}
	conf.TLS, err = buildTlsConfig(u)
	if err != nil {
		return nil, fmt.Errorf("build tls config from %s: %s", u.RawQuery, err)

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Print and inspect the exact metadata URL argument being passed to the command
  2. Percent-encode special characters in userinfo (password) and use `host:port` comma-separated endpoints without stray characters
  3. Test parsing locally: `python3 -c "import urllib.parse;urllib.parse.urlparse('<your-url>')"` or curl equivalent
  4. Correct the URL and rerun the command

Example fix

// before
juicefs mount 'etcd://host1:2379,host2:2379 p@ss@/prefix' /mnt/jfs
// after
juicefs mount 'etcd://user:p%40ss@host1:2379,host2:2379/prefix' /mnt/jfs
Defensive patterns

Strategy: validation

Validate before calling

// Validate the metadata URL before invoking juicefs
from urllib.parse import urlparse
u = urlparse(meta_url)
assert u.scheme == 'etcd' or '://' in meta_url, f'invalid etcd metadata URL: {meta_url}'
assert u.hostname, f'missing host in URL: {meta_url}'

Prevention

When it happens

Trigger: `juicefs mount ... etcd://<addr>` (or `etcd` scheme metadata URL) where the address after scheme handling is not a valid URL — bad characters, missing host, invalid userinfo, unescaped percent signs.

Common situations: Typo in the metadata URL; unescaped special characters (`@`, `:`, spaces) in host or password; passing a bare hostname with stray characters; quoting issues from shell escaping.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


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