juicedata/juicefs · error

Invalid endpoint: %v

Error message

Invalid endpoint: %v

What it means

After the endpoint parses as a URI, newBOS splits uri.Host on the first dot expecting "<bucket>.<region-domain>" (e.g. mybucket.bj.bcebos.com). If the host has no dot, no bucket name can be extracted and the constructor rejects the endpoint with this message.

Source

Thrown at pkg/object/bos.go:300

	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)
	// endpoint format like https://bj.bcebos.com
	bosClient, err := bos.NewClient(accessKey, secretKey, endpoint)
	if err != nil {
		return nil, err

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Use the virtual-hosted form: <bucket>.<region>.bcebos.com
  2. If using a custom domain, include the bucket as the first host label (e.g. mybucket.svc.example.com)
  3. Check the endpoint is not just the region domain (bj.bcebos.com) — the bucket label must be present

Example fix

// before
newBOS("https://bj.bcebos.com", ak, sk, "")
// after
newBOS("https://mybucket.bj.bcebos.com", ak, sk, "")
Defensive patterns

Strategy: validation

Validate before calling

// Go: ensure bucket-prefixed host with at least one dot
parts := strings.SplitN(u.Host, ".", 2)
if len(parts) != 2 || parts[0] == "" {
    return fmt.Errorf("endpoint host must be <bucket>.<domain>, got %q", u.Host)
}

Try / catch

// Go
obj, err := object.NewBOS(endpoint, ak, sk, "")
if err != nil && strings.Contains(err.Error(), "Invalid endpoint") {
    log.Fatalf("check BOS endpoint format <bucket>.<region>.bcebos.com: %v", err)
}

Prevention

When it happens

Trigger: Endpoints like "https://bcebos.com", "https://localhost", or "myendpoint" where the host portion contains no dot; also a URL whose scheme parsing left an empty host.

Common situations: Passing only the service domain instead of the bucket-prefixed virtual-host endpoint; using an IP-address endpoint for a self-hosted BOS-compatible service; forgetting to prefix the bucket name.

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/28c10bbc08aac21d. Report an issue: GitHub.