juicedata/juicefs · error
invalid scheme %s, should be cifs:// or smb://
Error message
invalid scheme %s, should be cifs:// or smb://
What it means
parseEndpoint in pkg/object/cifs.go validates the CIFS endpoint URL. If a scheme is present but is neither "cifs" nor "smb", the endpoint cannot be interpreted as a CIFS/SMB address, so newCifs refuses to build the storage backend. This prevents silently treating an http:// or ftp:// URL as an SMB share.
Source
Thrown at pkg/object/cifs.go:482
func (c *cifsStore) Copy(ctx context.Context, dst, src string) error {
r, err := c.Get(ctx, src, 0, -1)
if err != nil {
return err
}
defer r.Close()
return c.Put(ctx, dst, r)
}
func parseEndpoint(endpoint string) (host, port, share string, err error) {
if !strings.Contains(endpoint, "://") {
endpoint = "cifs://" + endpoint
}
u, err := url.Parse(endpoint)
if err != nil {
return
}
if u.Scheme != "" && (u.Scheme != "cifs" && u.Scheme != "smb") {
err = fmt.Errorf("invalid scheme %s, should be cifs:// or smb://", u.Scheme)
return
}
host = u.Hostname()
port = u.Port()
if port == "" {
port = "445" // Default SMB port
}
parts := strings.Split(u.Path, "/")
if len(parts) < 2 || parts[1] == "" {
err = fmt.Errorf("endpoint should be a valid share name (%s)", "\\\\<server>\\<share>")
return
}
if len(parts) > 2 && parts[2] != "" {
err = fmt.Errorf("endpoint should be a valid share name (%s)", "\\\\<server>\\<share>")
return
}
share = parts[1]View on GitHub (pinned to c9a67b23e8)
Solutions
- Use cifs://server/share or smb://server/share as the endpoint (the scheme is optional; a bare \\<server>\<share> or server/share also works).
- Fix any typo in the scheme so it is exactly "cifs" or "smb" (lowercase).
- If the share is actually served over HTTP/WebDAV, switch to the corresponding object storage/webdav driver instead of cifs.
Example fix
// before
newCifs("http://fileserver/myshare", ...)
// after
newCifs("cifs://fileserver/myshare", ...) Defensive patterns
Strategy: validation
Validate before calling
u, err := url.Parse(endpoint)
if err == nil && u.Scheme != "" && u.Scheme != "cifs" && u.Scheme != "smb" {
return fmt.Errorf("endpoint scheme %q not supported; use cifs:// or smb://", u.Scheme)
} Type guard
func isValidCifsScheme(endpoint string) bool {
u, err := url.Parse(endpoint)
return err == nil && (u.Scheme == "" || u.Scheme == "cifs" || u.Scheme == "smb")
} Try / catch
obj, err := object.CreateStorage("cifs", endpoint, ak, sk, "")
if err != nil {
if strings.Contains(err.Error(), "invalid scheme") {
// normalize endpoint: strip or fix scheme, then retry
}
} Prevention
- Validate the storage URI scheme before constructing the backend
- Use lowercase, exact scheme names cifs or smb
- Prefer the documented \\<server>\<share> or cifs://server/share formats
When it happens
Trigger: Calling newCifs (e.g. via juicefs object storage 'cifs' URI) with an endpoint like "http://server/share" or "ftp://host/share"; any non-empty u.Scheme that is not cifs or smb after url.Parse.
Common situations: Copy-pasting an HTTP URL of a file share instead of the SMB path; typos like "smbb://server/share"; tooling that auto-prefixes a wrong scheme; mixing up WebDAV/HTTP shares with SMB shares.
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
- endpoint should be a valid share name (%s)
- Invalid endpoint: %v, error: %v
- SMB authentication failed: %v
- failed to mount SMB share %s: %v
- CIFS username/ak is required
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/f45ebfd5ddaff2df.
Report an issue: GitHub.