{"record":{"id":"66acba292249d8b0","repo":"netbirdio/netbird","slug":"get-current-user-w","errorCode":null,"errorMessage":"get current user: %w","messagePattern":"get current user: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/profile.go","lineNumber":102,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc listProfilesFunc(cmd *cobra.Command, _ []string) error {\n\tif err := setupCmd(cmd); err != nil {\n\t\treturn err\n\t}\n\n\tconn, err := DialClientGRPCServer(cmd.Context(), daemonAddr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"connect to service CLI interface: %w\", err)\n\t}\n\tdefer conn.Close()\n\n\tcurrUser, err := user.Current()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get current user: %w\", err)\n\t}\n\n\tdaemonClient := proto.NewDaemonServiceClient(conn)\n\n\tresp, err := daemonClient.ListProfiles(cmd.Context(), &proto.ListProfilesRequest{\n\t\tUsername: currUser.Username,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttw := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 2, ' ', 0)\n\tif profileListShowID {\n\t\tfmt.Fprintln(tw, \"ID\\tNAME\\tACTIVE\")\n\t} else {\n\t\tfmt.Fprintln(tw, \"NAME\\tACTIVE\")\n\t}\n\tfor _, profile := range resp.Profiles {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/profile.go#L84-L120","documentation":"`netbird profile list` failed on os/user user.Current() before issuing ListProfiles; the username scopes the profile listing to the current OS user. With CGO disabled (static release binaries), Go parses /etc/passwd instead of using NSS, so an unresolvable UID errors here.","triggerScenarios":"UID without a passwd entry (container arbitrary UID, DynamicUser); /etc/passwd unreadable or shadowed by a bind mount; NSS failure in CGO builds; running as a numeric UID via `run -u`.","commonSituations":"Containers with synthetic UIDs; minimal/distroless images without passwd; enterprise NSS setups (LDAP) unreachable when the binary is CGO-disabled; cron/systemd units with UndefinedUser.","solutions":["Run the CLI from a normal login shell as a user listed in `getent passwd`","Fix the container image to include the UID in /etc/passwd (or mount the host passwd read-only)","Verify `id` and `getent passwd $(id -u)` succeed before retrying","For NSS-backed users, use a CGO-enabled build or run on the host"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := user.Current(); err != nil {\n    return fmt.Errorf(\"cannot resolve current user; add UID %d to /etc/passwd\", os.Getuid())\n}","typeGuard":"func userLookupWorks() bool { _, err := user.Current(); return err == nil }","tryCatchPattern":null,"preventionTips":["Run profile commands as the same OS user that owns the profiles","Container images should include a passwd entry for the runtime UID","Preflight `id -un` in scripts"],"tags":["os-user","environment","container","profiles"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}