{"record":{"id":"580b353dc2f9c298","repo":"juicedata/juicefs","slug":"invalid-endpoint-v-error-v","errorCode":null,"errorMessage":"Invalid endpoint: %v, error: %v","messagePattern":"Invalid endpoint: (.+?), error: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/azure.go","lineNumber":311,"sourceCode":"}\n\nfunc azblobOptions() *azblob.ClientOptions {\n\treturn &azblob.ClientOptions{\n\t\tClientOptions: azcore.ClientOptions{\n\t\t\tTelemetry: policy.TelemetryOptions{\n\t\t\t\tApplicationID: UserAgent,\n\t\t\t},\n\t\t},\n\t}\n}\n\nfunc newWasb(endpoint, accountName, accountKey, 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\tcontainerName := hostParts[0]\n\n\t// Priority 1: Connection string support\n\t// DefaultEndpointsProtocol=[http|https];AccountName=***;AccountKey=***;EndpointSuffix=[core.windows.net|core.chinacloudapi.cn]\n\tif connString := os.Getenv(\"AZURE_STORAGE_CONNECTION_STRING\"); connString != \"\" {\n\t\tlogger.Debugf(\"Using Azure connection string authentication\")\n\t\tvar client *azblob.Client\n\t\tif client, err = azblob.NewClientFromConnectionString(connString, azblobOptions()); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &wasb{container: client.ServiceClient().NewContainerClient(containerName), azblobCli: client, cName: containerName, useTokenAuth: false}, nil\n\t}\n\n\t// Priority 2: No account key — use SAS token or managed identity\n\tif accountKey == \"\" {\n\t\tdomain := domainFromHost(hostParts)","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/azure.go#L293-L329","documentation":"newWasb in azure.go validates the configured endpoint with url.ParseRequestURI before splitting it into container/account host parts. This error is returned when the endpoint string (after prefixing https:// when no scheme was given) is not a valid absolute URL, so the Azure Blob backend cannot be constructed.","triggerScenarios":"Passing an endpoint like \"myaccount.blob.core.windows.net/\" with a trailing path, \"http//missing-colon\", spaces, or other strings ParseRequestURI rejects to the Azure object storage constructor (also exercised by TestAzure).","commonSituations":"Typo'd AZURE_STORAGE_ENDPOINT values; copying an endpoint with a trailing slash+container; pasting a connection-string-like value into the endpoint field; missing scheme combined with characters that fail URI parsing.","solutions":["Set the endpoint to a clean absolute URL: https://<account>.blob.core.windows.net (no path, no spaces)","Let the code add the scheme by passing just the host without :// — but keep it a bare hostname otherwise","Check the environment/config value for stray quotes, spaces, or trailing slashes and correct them","Print/log the endpoint string actually received by newWasb to spot invisible characters"],"exampleFix":"// before\nendpoint = \"https://myaccount.blob.core.windows.net/mycontainer\"\n// after\nendpoint = \"https://myaccount.blob.core.windows.net\"","handlingStrategy":"validation","validationCode":"func validAzureEndpoint(ep string) bool {\n  if !strings.Contains(ep, \"://\") { ep = \"https://\" + ep }\n  u, err := url.ParseRequestURI(ep)\n  return err == nil && u.Host != \"\" && !strings.Contains(u.Path, \"/\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store endpoints as bare hostnames or scheme+host only, never with a container path","Trim spaces/quotes from endpoint env vars and config files","Unit-test endpoint parsing with the exact values used in deployment"],"tags":["azure","url","config","endpoint"],"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"}