netbirdio/netbird · error

get current user: %w

Error message

get current user: %w

What it means

`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.

Source

Thrown at client/cmd/profile.go:102

	}

	return nil
}

func listProfilesFunc(cmd *cobra.Command, _ []string) error {
	if err := setupCmd(cmd); err != nil {
		return err
	}

	conn, err := DialClientGRPCServer(cmd.Context(), daemonAddr)
	if err != nil {
		return fmt.Errorf("connect to service CLI interface: %w", err)
	}
	defer conn.Close()

	currUser, err := user.Current()
	if err != nil {
		return fmt.Errorf("get current user: %w", err)
	}

	daemonClient := proto.NewDaemonServiceClient(conn)

	resp, err := daemonClient.ListProfiles(cmd.Context(), &proto.ListProfilesRequest{
		Username: currUser.Username,
	})
	if err != nil {
		return err
	}

	tw := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 2, ' ', 0)
	if profileListShowID {
		fmt.Fprintln(tw, "ID\tNAME\tACTIVE")
	} else {
		fmt.Fprintln(tw, "NAME\tACTIVE")
	}
	for _, profile := range resp.Profiles {

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Run the CLI from a normal login shell as a user listed in `getent passwd`
  2. Fix the container image to include the UID in /etc/passwd (or mount the host passwd read-only)
  3. Verify `id` and `getent passwd $(id -u)` succeed before retrying
  4. For NSS-backed users, use a CGO-enabled build or run on the host
Defensive patterns

Strategy: validation

Validate before calling

if _, err := user.Current(); err != nil {
    return fmt.Errorf("cannot resolve current user; add UID %d to /etc/passwd", os.Getuid())
}

Type guard

func userLookupWorks() bool { _, err := user.Current(); return err == nil }

Prevention

When it happens

Trigger: 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`.

Common situations: 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.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/66acba292249d8b0. Report an issue: GitHub.