{"record":{"id":"ac718e819035294e","repo":"juicedata/juicefs","slug":"endpoint-should-be-a-valid-share-name-s","errorCode":null,"errorMessage":"endpoint should be a valid share name (%s)","messagePattern":"endpoint should be a valid share name \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/cifs.go","lineNumber":493,"sourceCode":"\t\tendpoint = \"cifs://\" + endpoint\n\t}\n\tu, err := url.Parse(endpoint)\n\tif err != nil {\n\t\treturn\n\t}\n\tif u.Scheme != \"\" && (u.Scheme != \"cifs\" && u.Scheme != \"smb\") {\n\t\terr = fmt.Errorf(\"invalid scheme %s, should be cifs:// or smb://\", u.Scheme)\n\t\treturn\n\t}\n\n\thost = u.Hostname()\n\tport = u.Port()\n\tif port == \"\" {\n\t\tport = \"445\" // Default SMB port\n\t}\n\tparts := strings.Split(u.Path, \"/\")\n\tif len(parts) < 2 || parts[1] == \"\" {\n\t\terr = fmt.Errorf(\"endpoint should be a valid share name (%s)\", \"\\\\\\\\<server>\\\\<share>\")\n\t\treturn\n\t}\n\tif len(parts) > 2 && parts[2] != \"\" {\n\t\terr = fmt.Errorf(\"endpoint should be a valid share name (%s)\", \"\\\\\\\\<server>\\\\<share>\")\n\t\treturn\n\t}\n\tshare = parts[1]\n\treturn\n}\n\nfunc newCifs(endpoint, username, password, _ string) (ObjectStorage, error) {\n\thost, port, share, err := parseEndpoint(endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif username == \"\" {\n\t\treturn nil, fmt.Errorf(\"CIFS username/ak is required\")\n\t}","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/cifs.go#L475-L511","documentation":"After parsing the endpoint URL, parseEndpoint requires the URL path to name exactly one share (u.Path must have a non-empty first segment and nothing after it). If the path is empty (len(parts) < 2) or parts[1] is empty, there is no share name, so the CIFS backend cannot be constructed.","triggerScenarios":"Endpoints like \"cifs://server\", \"cifs://server/\", \"cifs://server\" with no path, or \\\\<server> with no share component passed to newCifs.","commonSituations":"User configured only the server address without the share; trimmed/lost the share part when templating config; forgot that CIFS endpoints must always include the share.","solutions":["Append the share name to the endpoint: \"cifs://server/share\" (or \\\\<server>\\\\share).","Ensure the share segment is non-empty, not just a trailing slash.","Check the config file/URI for accidental truncation of the share name."],"exampleFix":"// before\nnewCifs(\"cifs://fileserver\", ...)\n// after\nnewCifs(\"cifs://fileserver/myshare\", ...)","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(endpoint)\nshare := strings.SplitN(u.Path, \"/\", 3)\nif len(share) < 2 || share[1] == \"\" {\n    return fmt.Errorf(\"endpoint must include a share: cifs://server/share\")\n}","typeGuard":"func hasShareName(endpoint string) bool {\n    u, err := url.Parse(endpoint)\n    if err != nil { return false }\n    parts := strings.Split(u.Path, \"/\")\n    return len(parts) >= 2 && parts[1] != \"\"\n}","tryCatchPattern":"obj, err := object.CreateStorage(\"cifs\", endpoint, ak, sk, \"\")\nif err != nil && strings.Contains(err.Error(), \"valid share name\") {\n    endpoint = fmt.Sprintf(\"cifs://%s/share\", host) // append default share and retry\n}","preventionTips":["Always include the share name in CIFS endpoints","Watch for config templating that drops the path portion","Test endpoint parsing at startup rather than at first use"],"tags":["cifs","smb","endpoint","config"],"backgroundTag":"invalid-argument-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"}