{"record":{"id":"ddcbd21ca9a0c196","repo":"juicedata/juicefs","slug":"invalid-endpoint-v-error-v-ddcbd2","errorCode":null,"errorMessage":"Invalid endpoint: %v, error: %v","messagePattern":"Invalid endpoint: (.+?), error: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/b2.go","lineNumber":163,"sourceCode":"\t\t\tf.ContentLength,\n\t\t\ttime.Unix(f.UploadTimestamp/1000, 0),\n\t\t\tstrings.HasSuffix(f.Name, \"/\"),\n\t\t\t\"\",\n\t\t\t\"\",\n\t\t})\n\t}\n\treturn objs, resp.NextFileName != \"\", resp.NextFileName, nil\n}\n\n// TODO: support multipart upload using S3 client\n\nfunc newB2(endpoint, keyID, applicationKey, 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.Split(uri.Host, \".\")\n\tname := hostParts[0]\n\t// TODO: set UserAgent once kothar/go-backblaze supports http.Client injection\n\tclient, err := backblaze.NewB2(backblaze.Credentials{\n\t\tKeyID:          keyID,\n\t\tApplicationKey: applicationKey,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create B2 client: %s\", err)\n\t}\n\tclient.MaxIdleUploads = 20\n\tbucket, err := client.Bucket(name)\n\tif err != nil {\n\t\tlogger.Warnf(\"access bucket %s: %s\", name, err)\n\t}\n\tif err == nil && bucket == nil {\n\t\tbucket, err = client.CreateBucket(name, \"allPrivate\")","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/b2.go#L145-L181","documentation":"Thrown by newB2 when the user-supplied Backblaze B2 endpoint cannot be parsed as a URI after the 'https://' scheme is prepended (when missing). It indicates the endpoint string is malformed — e.g. it contains invalid URI characters, an embedded space, or a badly formed host — so the B2 client cannot be constructed. This is a configuration-validation guard on the endpoint argument, not a network failure.","triggerScenarios":"Passing an endpoint that is empty, contains spaces or invalid characters, or is otherwise not a parseable URI to the b2 object storage constructor (juicefs b2:// endpoint).","commonSituations":"Endpoint config value with trailing whitespace or newline; endpoint given as a bucket name only; quotes or stray characters copied from config files; localized characters in hostname.","solutions":["Check the endpoint string for whitespace/newlines and trim it.","Use a valid hostname form, e.g. b2://<endpoint> with a proper host.","Ensure the endpoint starts with a scheme or is a bare hostname that https:// can be prefixed to.","Validate the URL in config before constructing the client."],"exampleFix":"// before\nendpoint: \" b2.backblaze.com \"   (spaces -> parse error)\n// after\nendpoint: \"b2.backblaze.com\"","handlingStrategy":"validation","validationCode":"endpoint = strings.TrimSpace(endpoint)\nif endpoint == \"\" { return errors.New(\"B2 endpoint is required\") }\nif !strings.Contains(endpoint, \"://\") { endpoint = \"https://\" + endpoint }\nif _, err := url.ParseRequestURI(endpoint); err != nil { return fmt.Errorf(\"invalid B2 endpoint %q: %w\", endpoint, err) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim whitespace/newlines from config values","Validate the endpoint URL at config-load time","Use bare hostnames or fully-qualified URLs consistently"],"tags":["b2","object-storage","url-validation","config"],"backgroundTag":"invalid-url","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}