netbirdio/netbird · error

get active profile file path: %v

Error message

get active profile file path: %v

What it means

activeProf.FilePath() could not produce the config file path for the active profile. Per client/internal/profilemanager/profilemanager.go:36 this fails when the Profile has neither ID nor Name (incomplete loader entry), the ID is not a valid filename stem, user.Current() fails (no resolvable OS user), or the per-user config directory cannot be determined. It is a structural/environment error, not a network one.

Source

Thrown at client/cmd/login.go:327

		return "", fmt.Errorf("switch profile failed: %w", err)
	}

	return profilemanager.ID(resp.Id), nil
}

func doForegroundLogin(ctx context.Context, cmd *cobra.Command, setupKey string, activeProf *profilemanager.Profile) error {

	err := handleRebrand(cmd)
	if err != nil {
		return err
	}

	// update host's static platform and system information
	system.UpdateStaticInfoAsync()

	configFilePath, err := activeProf.FilePath()
	if err != nil {
		return fmt.Errorf("get active profile file path: %v", err)

	}

	config, err := profilemanager.ReadConfig(configFilePath)
	if err != nil {
		return fmt.Errorf("read config file %s: %v", configFilePath, err)
	}

	// Mirror runInForegroundMode: recover residual state (DNS, firewall,
	// ssh config, legacy routing) from a previous unclean shutdown and
	// enable advanced routing before dialing management.
	if err := server.RestoreResidualState(ctx, profilemanager.NewServiceManager(configFilePath).GetStatePath()); err != nil {
		log.Warnf("failed to restore residual state: %v", err)
	}
	nbnet.Init()

	err = foregroundLogin(ctx, cmd, config, setupKey, activeProf.ID)
	if err != nil {

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Inspect the profiles file in the config dir and recreate the broken profile ('netbird profile create'), or delete the malformed entry
  2. Run the CLI as a real user with a valid HOME and passwd entry
  3. Verify NB_CONFIG_DIR / XDG_CONFIG_HOME resolve to an existing directory
  4. Avoid hand-editing profile JSON; use the profile subcommands
Defensive patterns

Strategy: validation

Validate before calling

// Reject structurally incomplete profiles before deriving a file path
if prof.ID == "" && prof.Name == "" {
    return fmt.Errorf("profile has empty ID and name; recreate it")
}
path, err := prof.FilePath()
if err != nil {
    return err
}

Type guard

// hasResolvablePath narrows profiles that can produce a config path
func hasResolvablePath(p profilemanager.Profile) bool {
    return p.ID != "" || p.Name != ""
}

Prevention

When it happens

Trigger: Hand-edited or corrupted profile JSON missing id/name fields; profile ID containing characters rejected by IsValidProfileFilenameStem; running in a minimal container/CI without a proper user database (user.Current fails); NB_CONFIG_DIR/XDG environment pointing somewhere unresolvable.

Common situations: Profile store edited by hand or by external tooling; Running the CLI as a UID with no passwd entry (some container runtimes); Config dir moved without updating environment variables

Related errors


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