{"record":{"id":"042f689a35d71916","repo":"juicedata/juicefs","slug":"cifs-username-ak-is-required","errorCode":null,"errorMessage":"CIFS username/ak is required","messagePattern":"CIFS username/ak is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/cifs.go","lineNumber":510,"sourceCode":"\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}\n\n\tif password == \"\" {\n\t\treturn nil, fmt.Errorf(\"CIFS password/sk is required\")\n\t}\n\n\tmaxPool := 8\n\tif v := os.Getenv(\"JFS_CIFS_MAX_POOL\"); v != \"\" {\n\t\tif n, err := strconv.Atoi(v); err == nil {\n\t\t\tmaxPool = n\n\t\t}\n\t}\n\n\tstore := &cifsStore{\n\t\thost:            host,\n\t\tport:            port,\n\t\tshare:           share,\n\t\tuser:            username,","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/cifs.go#L492-L528","documentation":"newCifs requires a username (mapped to the access-key parameter). CIFS/SMB authentication needs a user identity for the session setup; an empty username means the client cannot authenticate to the share, so construction fails immediately after endpoint parsing.","triggerScenarios":"Calling newCifs(endpoint, \"\", password, _) — e.g. object storage URI with missing access key part, or TestCifs/TestCifs2 variants passing an empty username.","commonSituations":"Guest/anonymous shares where the user omitted credentials assuming they are optional; environment variables or config where the access-key field was not set; credential management systems dropping empty values.","solutions":["Supply a valid SMB username as the access-key parameter of the cifs storage URI.","If the share allows guest access, still provide the guest username (often \"guest\" or \"nobody\").","Check that the access-key env/config field is populated before invoking newCifs."],"exampleFix":"// before\nnewCifs(\"cifs://server/share\", \"\", \"secret\")\n// after\nnewCifs(\"cifs://server/share\", \"smbuser\", \"secret\")","handlingStrategy":"validation","validationCode":"if ak == \"\" {\n    return fmt.Errorf(\"cifs storage requires a username (access key); got empty value\")\n}","typeGuard":null,"tryCatchPattern":"obj, err := object.CreateStorage(\"cifs\", endpoint, ak, sk, \"\")\nif err != nil && strings.Contains(err.Error(), \"username/ak is required\") {\n    return fmt.Errorf(\"missing SMB credentials: set access key to the SMB username\")\n}","preventionTips":["Always populate the access-key field for cifs URIs, even for guest shares","Validate credentials exist before constructing storage in startup code","Watch for CI secret injection producing empty strings"],"tags":["cifs","smb","authentication","credentials"],"backgroundTag":"missing-credentials","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"}