{"record":{"id":"ad9eb9cf8124a9aa","repo":"juicedata/juicefs","slug":"invalid-endpoint-v-error-v-ad9eb9","errorCode":null,"errorMessage":"Invalid endpoint: %v, error: %v","messagePattern":"Invalid endpoint: (.+?), error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/gs.go","lineNumber":203,"sourceCode":"\t\t}\n\t}\n\tif delimiter != \"\" {\n\t\tsort.Slice(objs, func(i, j int) bool { return objs[i].Key() < objs[j].Key() })\n\t}\n\treturn objs, nextPageToken != \"\", nextPageToken, nil\n}\n\n// Restore GCS does not support restoring objects to a temporary readable state.\nfunc (g *gs) Restore(ctx context.Context, key string, days int32) error {\n\treturn notSupported\n}\nfunc newGS(endpoint, accessKey, secretKey, token string) (ObjectStorage, error) {\n\tif !strings.Contains(endpoint, \"://\") {\n\t\tendpoint = fmt.Sprintf(\"gs://%s\", endpoint)\n\t}\n\turi, err := url.ParseRequestURI(endpoint)\n\tif err != nil {\n\t\treturn nil, errors.Errorf(\"Invalid endpoint: %v, error: %v\", endpoint, err)\n\t}\n\thostParts := strings.Split(uri.Host, \".\")\n\tbucket := hostParts[0]\n\tvar region string\n\tif len(hostParts) > 1 {\n\t\tregion = hostParts[1]\n\t}\n\n\tvar size int\n\tif ssize := os.Getenv(\"JFS_NUM_GOOGLE_CLIENTS\"); ssize != \"\" {\n\t\tif size, err = strconv.Atoi(ssize); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif size < 1 {\n\t\tsize = 5\n\t}\n\tclis := make([]*storage.Client, size)","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/gs.go#L185-L221","documentation":"newGS validates the GCS endpoint by parsing it as a URL; if url.ParseRequestURI fails it returns this error. It means the endpoint string supplied to the gs object storage backend is not a parseable absolute URI. The library auto-prefixes `gs://` when no scheme is present, so even bare hostnames must otherwise be well-formed.","triggerScenarios":"Calling newGS (directly or via `juicefs format`/object storage selection) with a malformed endpoint such as `gs://[bad`, `gs://host:.:port`, or a string containing invalid URL characters so url.ParseRequestURI fails.","commonSituations":"Typo or stray whitespace/control characters in the endpoint passed via --storage gs and --endpoint, copy-pasting an endpoint with quotes or trailing characters, or environments where the endpoint is assembled from variables that are empty or malformed.","solutions":["Print and inspect the endpoint value; correct malformed characters, quotes, or whitespace","Use a valid form like `gs://bucket.storage.googleapis.com` or `gs://bucket` (scheme is added automatically)","If building the endpoint from env vars, ensure the variable is set and trimmed","Validate locally with url.ParseRequestURI before passing the endpoint"],"exampleFix":"// before\nendpoint := \"gs://bucket..storage.googleapis.com:badport\"\n// after\nendpoint := \"gs://mybucket.storage.googleapis.com\"","handlingStrategy":"validation","validationCode":"u, err := url.ParseRequestURI(strings.Contains(ep, \"://\") ? ep : \"gs://\"+ep)\nif err != nil { return fmt.Errorf(\"invalid gs endpoint %q: %v\", ep, err) }","typeGuard":"func validGSEndpoint(ep string) bool {\n  if !strings.Contains(ep, \"://\") { ep = \"gs://\" + ep }\n  _, err := url.ParseRequestURI(ep)\n  return err == nil\n}","tryCatchPattern":"gs, err := newGS(endpoint, ak, sk, token)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"Invalid endpoint\") { return fmt.Errorf(\"check --endpoint format: %w\", err) }\n    return err\n}","preventionTips":["Always include a scheme or use a plain well-formed host","Trim whitespace and shell quotes from endpoint inputs","Validate endpoints with url.ParseRequestURI in config pipelines","Prefer documented endpoint forms: gs://bucket or gs://bucket.storage.googleapis.com"],"tags":["gcs","url","configuration","object-storage"],"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"}