juicedata/juicefs · error
invalid uri: %s
Error message
invalid uri: %s
What it means
Returned by injectPasswordIntoURI when the metadata URL contains no '@' separator, i.e. there is no userinfo section into which a password could be injected. The URI is structurally invalid for credential injection.
Source
Thrown at pkg/meta/interface.go:596
Slices map[Ino][]Slice
}
type CleanupTrashStats struct {
DeletedFiles int64
}
type Creator func(driver, addr string, conf *Config) (Meta, error)
var metaDrivers = make(map[string]Creator)
func Register(name string, register Creator) {
metaDrivers[name] = register
}
func injectPasswordIntoURI(uri, password string) (string, error) {
atIndex := strings.LastIndex(uri, "@")
if atIndex == -1 {
return "", fmt.Errorf("invalid uri: %s", uri)
}
dIndex := strings.Index(uri, "://") + 3
s := strings.Split(uri[dIndex:atIndex], ":")
if len(s) > 2 {
return "", fmt.Errorf("invalid uri: %s", uri)
}
if len(s) == 2 && s[1] != "" {
return uri, nil
}
pwd := url.UserPassword("", password) // escape only password
return uri[:dIndex] + s[0] + pwd.String() + uri[atIndex:], nil
}
func readPasswordFromFile(filePath string) (string, error) {
content, err := os.ReadFile(filePath)
if err != nil {View on GitHub (pinned to c9a67b23e8)
Solutions
- Include a user (and empty password) in the URI before '@', e.g. `redis://:PASSWORD@host:6379/1` or `redis://default@host:6379/1`.
- Remove the --password/env password so no injection is attempted and embed credentials directly in the URI.
- Double-check the URI has no typos that removed the '@' (e.g. shell mangling of special characters).
Example fix
// before --meta redis://localhost:6379/1 --password secretpw // after --meta redis://default@localhost:6379/1 --password secretpw
Defensive patterns
Strategy: validation
Validate before calling
case "$META_URL" in *@*) echo ok;; *) echo "URI missing user@host part";; esac
Prevention
- Always include user@host in metadata URIs when using --password.
- Quote URIs in shell scripts to avoid character mangling.
- Document credential-injection requirements in deployment templates.
When it happens
Trigger: setPasswordFromEnv / password injection is invoked (e.g. --password or password env var set) with a metadata URI lacking a userinfo '@', such as `redis://localhost:6379/1`.
Common situations: Setting JFS_*_PASSWORD or passing --password while the URL omits a user@host part; copy-pasting a connection string without credentials and expecting the tool to inject them.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/eac9e98e5e59f4d4.
Report an issue: GitHub.