juicedata/juicefs · error
invalid endpoint %s: %q
Error message
invalid endpoint %s: %q
What it means
newOBS normalizes the endpoint (adds https:// if no scheme) then parses it with url.ParseRequestURI. If parsing fails, the endpoint is malformed and the constructor aborts with 'invalid endpoint <endpoint>: <parse error>'.
Source
Thrown at pkg/object/obs.go:390
if err != nil {
return "", err
}
for _, bucket := range result.Buckets {
if bucket.Name == bucketName {
logger.Debugf("Get location of bucket %q: %s", bucketName, bucket.Location)
return fmt.Sprintf("obs.%s.myhuaweicloud.com", bucket.Location), nil
}
}
return "", fmt.Errorf("bucket %q does not exist", bucketName)
}
func newOBS(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 %s: %q", endpoint, err)
}
hostParts := strings.SplitN(uri.Host, ".", 2)
bucketName := hostParts[0]
if len(hostParts) > 1 {
endpoint = fmt.Sprintf("%s://%s", uri.Scheme, hostParts[1])
}
if accessKey == "" {
accessKey = os.Getenv("HWCLOUD_ACCESS_KEY")
secretKey = os.Getenv("HWCLOUD_SECRET_KEY")
}
var region string
if len(hostParts) == 1 {
if endpoint, err = autoOBSEndpoint(bucketName, accessKey, secretKey, token); err != nil {
return nil, fmt.Errorf("cannot get location of bucket %s: %q", bucketName, err)
}
if !strings.HasPrefix(endpoint, "http") {View on GitHub (pinned to c9a67b23e8)
Solutions
- Print and inspect the endpoint string for stray whitespace/characters
- Ensure it is a valid host like obs.cn-north-1.myhuaweicloud.com or a full https:// URL
- Quote shell variables to avoid word-splitting artifacts
- Remove any path suffix or credentials accidentally embedded in the endpoint
Example fix
// before endpoint := "obs.cn-north-1.myhuaweicloud.com/ " // after endpoint := "obs.cn-north-1.myhuaweicloud.com"
Defensive patterns
Strategy: validation
Validate before calling
if _, err := url.ParseRequestURI(endpoint); err != nil {
return fmt.Errorf("bad obs endpoint: %w", err)
} Try / catch
store, err := object.CreateStorage("obs", endpoint, ak, sk, "")
if err != nil && strings.Contains(err.Error(), "invalid endpoint") {
// sanitize endpoint and retry
} Prevention
- Trim whitespace from endpoints read from env/config
- Always include scheme and host
- Validate endpoints at config-load time with url.ParseRequestURI
When it happens
Trigger: Endpoint string that is not a valid absolute URI even after prefixing https:// — e.g. empty string, contains spaces, control characters, or 'https://bucket host' with invalid characters.
Common situations: Empty --endpoint flag; copy-pasted endpoint with stray whitespace; endpoint with unsupported scheme characters; passing a path instead of a host.
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
- invalid endpoint: %v, error: %v
- Invalid endpoint %s: %s
- Invalid endpoint %s: %s
- fail to auto-detect endpoint: %w
- Invalid endpoint: %v, error: %v
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/8d630b05cd35a6c7.
Report an issue: GitHub.