{"record":{"id":"5c7072a25c7e639f","repo":"juicedata/juicefs","slug":"get-current-user-s","errorCode":null,"errorMessage":"get current user: %s","messagePattern":"get current user: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/hdfs.go","lineNumber":325,"sourceCode":"\toptions := hdfs.ClientOptionsFromConf(conf)\n\tif addr != \"\" {\n\t\toptions.Addresses = rpcAddr\n\t\tlogger.Infof(\"HDFS Addresses: %s, basePath: %s\", rpcAddr, basePath)\n\t}\n\n\tif options.KerberosClient != nil {\n\t\toptions.KerberosClient, err = getKerberosClient()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Problem with kerberos authentication: %s\", err)\n\t\t}\n\t} else {\n\t\tif username == \"\" {\n\t\t\tusername = os.Getenv(\"HADOOP_USER_NAME\")\n\t\t}\n\t\tif username == \"\" {\n\t\t\tcurrent, err := user.Current()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"get current user: %s\", err)\n\t\t\t}\n\t\t\tusername = current.Username\n\t\t}\n\t\toptions.User = username\n\t}\n\n\tc, err := hdfs.NewClient(options)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"new HDFS client %s: %s\", rpcAddr, err)\n\t}\n\tif os.Getenv(\"HADOOP_SUPER_USER\") != \"\" {\n\t\tsuperuser = os.Getenv(\"HADOOP_SUPER_USER\")\n\t}\n\tif os.Getenv(\"HADOOP_SUPER_GROUP\") != \"\" {\n\t\tsupergroup = os.Getenv(\"HADOOP_SUPER_GROUP\")\n\t}\n\n\tvar replication = 3","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/hdfs.go#L307-L343","documentation":"For non-Kerberos clusters newHDFS derives the HDFS user: an explicit username argument, then HADOOP_USER_NAME, then the OS current user via user.Current(). If user.Current() fails (OS account lookup error), the client creation aborts with \"get current user: %s\". This happens only when no username was supplied and HADOOP_USER_NAME is empty.","triggerScenarios":"newHDFS invoked without a username and without HADOOP_USER_NAME set, on a system where user.Current() fails — e.g. statically linked binary without cgo unable to resolve the uid to a passwd entry, or the process running under a uid with no /etc/passwd entry (common in minimal containers).","commonSituations":"Running the static (musl) JuiceFS binary in a scratch/alpine container whose user has no passwd entry; running as an arbitrary --user uid in Docker; nsswitch misconfiguration.","solutions":["Set HADOOP_USER_NAME to a valid HDFS user so user.Current() is never called.","Pass the username explicitly where the object storage is registered (the username argument of newHDFS).","Ensure a /etc/passwd entry exists for the process uid (adduser/echo to passwd in the container).","If using the static binary, prefer setting HADOOP_USER_NAME over relying on cgo-based user lookup."],"exampleFix":"// before\n$ ./juicefs -static mount hdfs://nn:9000/data /mnt/jfs   # uid 10001, no passwd entry\nget current user: user: unknown userid 10001\n// after\n$ export HADOOP_USER_NAME=hdfs\n$ ./juicefs -static mount hdfs://nn:9000/data /mnt/jfs","handlingStrategy":"validation","validationCode":"if os.Getenv(\"HADOOP_USER_NAME\") == \"\" {\n    if _, err := user.Current(); err != nil {\n        return fmt.Errorf(\"set HADOOP_USER_NAME: cannot resolve current user: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"os, err := object.CreateStorage(\"hdfs\", addr, \"\", \"\")\nif err != nil && strings.Contains(err.Error(), \"get current user\") {\n    logger.Fatalf(\"HDFS user lookup failed: %v — set HADOOP_USER_NAME explicitly\", err)\n}","preventionTips":["Always set HADOOP_USER_NAME in containers or when using static binaries.","Give the process uid a /etc/passwd entry (adduser) in minimal images.","Pass the username explicitly when registering HDFS storage instead of relying on OS lookup.","Test user resolution in your container before production rollout."],"tags":["hdfs","user-lookup","object-storage","container"],"backgroundTag":"user-not-found","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"}