juicedata/juicefs · error
Invalid endpoint: %v, error: %v
Error message
Invalid endpoint: %v, error: %v
What it means
newBOS builds a Baidu Object Storage client from an endpoint URL. After prepending https:// if a scheme is missing, it parses the endpoint with url.ParseRequestURI; if that parse fails, the endpoint is not a valid absolute URI and the constructor aborts with this message including the parse error.
Source
Thrown at pkg/object/bos.go:296
bosCli, err := bos.NewClient(accessKey, secretKey, endpoint)
if err != nil {
return "", err
}
if location, err := bosCli.GetBucketLocation(bucketName); err != nil {
return "", err
} else {
return fmt.Sprintf("%s.bcebos.com", location), nil
}
}
func newBOS(endpoint, accessKey, secretKey, 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.SplitN(uri.Host, ".", 2)
if len(hostParts) != 2 {
return nil, fmt.Errorf("Invalid endpoint: %v", endpoint)
}
bucketName := hostParts[0]
if accessKey == "" {
accessKey = os.Getenv("BDCLOUD_ACCESS_KEY")
secretKey = os.Getenv("BDCLOUD_SECRET_KEY")
}
endpoint = hostParts[1]
if hostParts[1] == "bcebos.com" {
if endpoint, err = autoBOSEndpoint(bucketName, accessKey, secretKey); err != nil {
return nil, fmt.Errorf("Fail to get location of bucket %q: %s", bucketName, err)
}
}
endpoint = fmt.Sprintf("%s://%s", uri.Scheme, endpoint)
logger.Debugf("Use endpoint: %s", endpoint)View on GitHub (pinned to c9a67b23e8)
Solutions
- Fix the endpoint to be a valid absolute URI, e.g. https://mybucket.bj.bcebos.com
- Ensure a scheme is present (or rely on the automatic https:// prefix) and remove stray whitespace/quotes
- Verify the endpoint is non-empty in your config/env (BOS_ENDPOINT)
- Test with `juicefs gateway`/`mount` using the corrected endpoint
Example fix
// before
newBOS("mybucket.bj..bcebos com", ak, sk, "")
// after
newBOS("mybucket.bj.bcebos.com", ak, sk, "") Defensive patterns
Strategy: validation
Validate before calling
// Go: validate before calling
u, err := url.ParseRequestURI(endpoint)
if err != nil || u.Host == "" {
return fmt.Errorf("invalid BOS endpoint: %q", endpoint)
} Try / catch
// Go
obj, err := object.NewBOS(endpoint, ak, sk, token)
if err != nil && strings.Contains(err.Error(), "Invalid endpoint") {
// surface config problem to operator, don't retry
} Prevention
- Store endpoints with scheme and full bucket-prefixed host in config
- Trim whitespace/quotes from env-sourced endpoint values
- Add a config lint step that parses all storage endpoints as URLs before deploy
When it happens
Trigger: Passing an endpoint that cannot be parsed as an absolute URI, e.g. empty string, "bos" without host, "https://" with malformed URL characters, or an endpoint with spaces/invalid chars. Also raised by TestBOS when constructing a BOS client with a bad endpoint.
Common situations: Typo in --storage-endpoint when mounting with BOS object storage; missing scheme combined with a malformed host; environment config interpolation producing an empty endpoint; copy-pasting an endpoint with trailing whitespace or quotes.
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
- Invalid endpoint: %v
- Invalid endpoint %s: %s
- object storage: %s
- failed to parse value as int: %v
- parse url %s failed: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/31334bb1159b5219.
Report an issue: GitHub.