{"record":{"id":"31334bb1159b5219","repo":"juicedata/juicefs","slug":"invalid-endpoint-v-error-v-31334b","errorCode":null,"errorMessage":"Invalid endpoint: %v, error: %v","messagePattern":"Invalid endpoint: (.+?), error: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/bos.go","lineNumber":296,"sourceCode":"\tbosCli, err := bos.NewClient(accessKey, secretKey, endpoint)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif location, err := bosCli.GetBucketLocation(bucketName); err != nil {\n\t\treturn \"\", err\n\t} else {\n\t\treturn fmt.Sprintf(\"%s.bcebos.com\", location), nil\n\t}\n}\n\nfunc newBOS(endpoint, accessKey, secretKey, token string) (ObjectStorage, error) {\n\tif !strings.Contains(endpoint, \"://\") {\n\t\tendpoint = fmt.Sprintf(\"https://%s\", endpoint)\n\t}\n\turi, err := url.ParseRequestURI(endpoint)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Invalid endpoint: %v, error: %v\", endpoint, err)\n\t}\n\thostParts := strings.SplitN(uri.Host, \".\", 2)\n\tif len(hostParts) != 2 {\n\t\treturn nil, fmt.Errorf(\"Invalid endpoint: %v\", endpoint)\n\t}\n\tbucketName := hostParts[0]\n\tif accessKey == \"\" {\n\t\taccessKey = os.Getenv(\"BDCLOUD_ACCESS_KEY\")\n\t\tsecretKey = os.Getenv(\"BDCLOUD_SECRET_KEY\")\n\t}\n\tendpoint = hostParts[1]\n\tif hostParts[1] == \"bcebos.com\" {\n\t\tif endpoint, err = autoBOSEndpoint(bucketName, accessKey, secretKey); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Fail to get location of bucket %q: %s\", bucketName, err)\n\t\t}\n\t}\n\tendpoint = fmt.Sprintf(\"%s://%s\", uri.Scheme, endpoint)\n\tlogger.Debugf(\"Use endpoint: %s\", endpoint)","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/bos.go#L278-L314","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnewBOS(\"mybucket.bj..bcebos com\", ak, sk, \"\")\n// after\nnewBOS(\"mybucket.bj.bcebos.com\", ak, sk, \"\")","handlingStrategy":"validation","validationCode":"// Go: validate before calling\nu, err := url.ParseRequestURI(endpoint)\nif err != nil || u.Host == \"\" {\n    return fmt.Errorf(\"invalid BOS endpoint: %q\", endpoint)\n}","typeGuard":null,"tryCatchPattern":"// Go\nobj, err := object.NewBOS(endpoint, ak, sk, token)\nif err != nil && strings.Contains(err.Error(), \"Invalid endpoint\") {\n    // surface config problem to operator, don't retry\n}","preventionTips":["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"],"tags":["object-storage","baidu-bos","url-parsing","configuration"],"backgroundTag":"invalid-url","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}