{"record":{"id":"8d630b05cd35a6c7","repo":"juicedata/juicefs","slug":"invalid-endpoint-s-q","errorCode":null,"errorMessage":"invalid endpoint %s: %q","messagePattern":"invalid endpoint (.+?): %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/obs.go","lineNumber":390,"sourceCode":"\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tfor _, bucket := range result.Buckets {\n\t\tif bucket.Name == bucketName {\n\t\t\tlogger.Debugf(\"Get location of bucket %q: %s\", bucketName, bucket.Location)\n\t\t\treturn fmt.Sprintf(\"obs.%s.myhuaweicloud.com\", bucket.Location), nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"bucket %q does not exist\", bucketName)\n}\n\nfunc newOBS(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 %s: %q\", endpoint, err)\n\t}\n\thostParts := strings.SplitN(uri.Host, \".\", 2)\n\tbucketName := hostParts[0]\n\tif len(hostParts) > 1 {\n\t\tendpoint = fmt.Sprintf(\"%s://%s\", uri.Scheme, hostParts[1])\n\t}\n\n\tif accessKey == \"\" {\n\t\taccessKey = os.Getenv(\"HWCLOUD_ACCESS_KEY\")\n\t\tsecretKey = os.Getenv(\"HWCLOUD_SECRET_KEY\")\n\t}\n\n\tvar region string\n\tif len(hostParts) == 1 {\n\t\tif endpoint, err = autoOBSEndpoint(bucketName, accessKey, secretKey, token); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot get location of bucket %s: %q\", bucketName, err)\n\t\t}\n\t\tif !strings.HasPrefix(endpoint, \"http\") {","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/obs.go#L372-L408","documentation":"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>'.","triggerScenarios":"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.","commonSituations":"Empty --endpoint flag; copy-pasted endpoint with stray whitespace; endpoint with unsupported scheme characters; passing a path instead of a host.","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"],"exampleFix":"// before\nendpoint := \"obs.cn-north-1.myhuaweicloud.com/ \"\n// after\nendpoint := \"obs.cn-north-1.myhuaweicloud.com\"","handlingStrategy":"validation","validationCode":"if _, err := url.ParseRequestURI(endpoint); err != nil {\n\treturn fmt.Errorf(\"bad obs endpoint: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"store, err := object.CreateStorage(\"obs\", endpoint, ak, sk, \"\")\nif err != nil && strings.Contains(err.Error(), \"invalid endpoint\") {\n\t// sanitize endpoint and retry\n}","preventionTips":["Trim whitespace from endpoints read from env/config","Always include scheme and host","Validate endpoints at config-load time with url.ParseRequestURI"],"tags":["obs","endpoint","url-parse"],"backgroundTag":"invalid-url-format","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"}