juicedata/juicefs · error
Invalid endpoint: %v, error: %v
Error message
Invalid endpoint: %v, error: %v
What it means
Thrown by newB2 when the user-supplied Backblaze B2 endpoint cannot be parsed as a URI after the 'https://' scheme is prepended (when missing). It indicates the endpoint string is malformed — e.g. it contains invalid URI characters, an embedded space, or a badly formed host — so the B2 client cannot be constructed. This is a configuration-validation guard on the endpoint argument, not a network failure.
Source
Thrown at pkg/object/b2.go:163
f.ContentLength,
time.Unix(f.UploadTimestamp/1000, 0),
strings.HasSuffix(f.Name, "/"),
"",
"",
})
}
return objs, resp.NextFileName != "", resp.NextFileName, nil
}
// TODO: support multipart upload using S3 client
func newB2(endpoint, keyID, applicationKey, token string) (ObjectStorage, error) {
if !strings.Contains(endpoint, "://") {
endpoint = fmt.Sprintf("https://%s", endpoint)
}
uri, err := url.ParseRequestURI(endpoint)
if err != nil {
return nil, fmt.Errorf("Invalid endpoint: %v, error: %v", endpoint, err)
}
hostParts := strings.Split(uri.Host, ".")
name := hostParts[0]
// TODO: set UserAgent once kothar/go-backblaze supports http.Client injection
client, err := backblaze.NewB2(backblaze.Credentials{
KeyID: keyID,
ApplicationKey: applicationKey,
})
if err != nil {
return nil, fmt.Errorf("create B2 client: %s", err)
}
client.MaxIdleUploads = 20
bucket, err := client.Bucket(name)
if err != nil {
logger.Warnf("access bucket %s: %s", name, err)
}
if err == nil && bucket == nil {
bucket, err = client.CreateBucket(name, "allPrivate")View on GitHub (pinned to c9a67b23e8)
Solutions
- Check the endpoint string for whitespace/newlines and trim it.
- Use a valid hostname form, e.g. b2://<endpoint> with a proper host.
- Ensure the endpoint starts with a scheme or is a bare hostname that https:// can be prefixed to.
- Validate the URL in config before constructing the client.
Example fix
// before endpoint: " b2.backblaze.com " (spaces -> parse error) // after endpoint: "b2.backblaze.com"
Defensive patterns
Strategy: validation
Validate before calling
endpoint = strings.TrimSpace(endpoint)
if endpoint == "" { return errors.New("B2 endpoint is required") }
if !strings.Contains(endpoint, "://") { endpoint = "https://" + endpoint }
if _, err := url.ParseRequestURI(endpoint); err != nil { return fmt.Errorf("invalid B2 endpoint %q: %w", endpoint, err) } Prevention
- Trim whitespace/newlines from config values
- Validate the endpoint URL at config-load time
- Use bare hostnames or fully-qualified URLs consistently
When it happens
Trigger: Passing an endpoint that is empty, contains spaces or invalid characters, or is otherwise not a parseable URI to the b2 object storage constructor (juicefs b2:// endpoint).
Common situations: Endpoint config value with trailing whitespace or newline; endpoint given as a bucket name only; quotes or stray characters copied from config files; localized characters in hostname.
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
- format decrypt: %s
- object storage: %s
- Failed to create Azure blob client with SAS token: %v
- Failed to create Azure blob client with token credential: %v
- create B2 client: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/ddcbd21ca9a0c196.
Report an issue: GitHub.