{"record":{"id":"938fa8fd14269154","repo":"juicedata/juicefs","slug":"url-parse-s-s","errorCode":null,"errorMessage":"url parse %s: %s","messagePattern":"url parse (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis.go","lineNumber":114,"sourceCode":"\tshaResolve string // The SHA returned by Redis for the loaded `scriptResolve`\n\tcache      *redisCache\n}\n\nvar _ Meta = (*redisMeta)(nil)\nvar _ engine = (*redisMeta)(nil)\n\nfunc init() {\n\tRegister(\"redis\", newRedisMeta)\n\tRegister(\"rediss\", newRedisMeta)\n\tRegister(\"unix\", newRedisMeta)\n}\n\n// newRedisMeta return a meta store using Redis.\nfunc newRedisMeta(driver, addr string, conf *Config) (Meta, error) {\n\turi := driver + \"://\" + addr\n\tu, err := url.Parse(uri)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"url parse %s: %s\", uri, err)\n\t}\n\tvalues := u.Query()\n\tquery := queryMap{&values}\n\tminRetryBackoff := query.duration(\"min-retry-backoff\", \"min_retry_backoff\", time.Millisecond*20)\n\tmaxRetryBackoff := query.duration(\"max-retry-backoff\", \"max_retry_backoff\", time.Second*10)\n\treadTimeout := query.duration(\"read-timeout\", \"read_timeout\", time.Second*30)\n\twriteTimeout := query.duration(\"write-timeout\", \"write_timeout\", time.Second*5)\n\trouteRead := query.pop(\"route-read\")\n\tskipVerify := query.pop(\"insecure-skip-verify\")\n\tcertFile := query.pop(\"tls-cert-file\")\n\tkeyFile := query.pop(\"tls-key-file\")\n\tcaCertFile := query.pop(\"tls-ca-cert-file\")\n\ttlsServerName := query.pop(\"tls-server-name\")\n\n\t// Client-side caching options\n\tclientCacheStr := query.pop(\"client-cache\")\n\tclientCache := clientCacheStr != \"false\" && clientCacheStr != \"\"\n\tclientCacheSize := query.getInt(\"client-cache-size\", \"client_cache_size\", 12800)","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis.go#L96-L132","documentation":"newRedisMeta (pkg/meta/redis.go:111-115) builds the URI as `driver + \"://\" + addr` (e.g. `redis://host:6379`) and parses it with net/url.Parse before handing it to the redis client. If the resulting string is not a valid URL, the client cannot be constructed and this error is returned wrapping the parse failure. It almost always means the address portion contained characters that are illegal in a URL or an empty/malformed host.","triggerScenarios":"Calling `juicefs mount redis://...` / `NewMeta` with a redis address containing spaces, stray quotes, unmatched brackets (e.g. `redis://[::1`), control characters, or an empty addr; also passing a full URL with an illegal scheme part into addr.","commonSituations":"Copy-pasted address with trailing whitespace or quotes from config/env; IPv6 literal missing brackets; credentials with special characters not percent-encoded in the URL; shell variable expansion leaving the address empty.","solutions":["Print the exact `driver://addr` string from the error and fix illegal characters (spaces, quotes, stray brackets).","For IPv6, wrap the host in brackets: `redis://[::1]:6379`.","Percent-encode special characters in embedded username/password (e.g. `redis://user:p%40ss@host:6379`).","Ensure the env var/config actually contains the address (an empty addr yields `redis://` which may fail downstream checks)."],"exampleFix":"// before\nmetaUrl := \"redis://\" + os.Getenv(\"REDIS_HOST\") // REDIS_HOST=\" 127.0.0.1:6379 \" -> url parse fails\n// after\nmetaUrl := \"redis://\" + strings.TrimSpace(os.Getenv(\"REDIS_HOST\"))","handlingStrategy":"validation","validationCode":"// validate the meta URL before invoking JuiceFS\nu, err := url.Parse(metaURL)\nif err != nil { return fmt.Errorf(\"invalid meta URL %q: %w\", metaURL, err) }\nif u.Host == \"\" { return fmt.Errorf(\"meta URL %q has no host\", metaURL) }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"url parse \") {\n\treturn fmt.Errorf(\"check REDIS address for illegal characters/brackets: %w\", err)\n}","preventionTips":["Trim whitespace/quotes from addresses read from env or config files.","Always bracket IPv6 literals: redis://[::1]:6379.","Percent-encode credentials embedded in URLs.","Test the URL with `url.Parse` in a script before deploying."],"tags":["redis","url","config","parsing"],"backgroundTag":"invalid-url-format","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"}