[PR #6479] [client] Fix profile regressions in up --profile and status #28304

Open
opened 2026-08-05 08:06:08 -04:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/6479

State: closed
Merged: Yes


Describe your changes

PR #6367 (migrating profile identity from display name to ID) introduced two regressions in the CLI profile flow. This PR fixes both.

  1. netbird up --profile <name> no longer auto-created a missing profile. Before #6367, switching to a non-existent profile name simply recorded it as the active profile and the config file was created lazily. After the migration, the daemon resolves the supplied handle against existing profiles and returns codes.NotFound, which broke ephemeral CI workflows relying on netbird up --profile <name> --setup-key <key> to provision the profile on the fly (reported in discussion #6476).

    upFunc in client/cmd/up.go now detects codes.NotFound from switchProfile, creates the profile via the daemon's existing AddProfile RPC (createProfile helper in client/cmd/login.go), and retries the switch. To make the status code inspectable by the caller, switchProfile now wraps the daemon error with %w instead of %v.

  2. netbird status showed an empty Profile: field for both the default and custom profiles. After #6367, ProfileManager.GetActiveProfile returns only the profile ID (not the display name), and the CLI — running as the invoking user — cannot read the per-user profile files under /var/lib/netbird/<user>/ (root-owned, 0700) to resolve the name itself.

    client/cmd/status.go now resolves the display name through the daemon's existing GetActiveProfile RPC, which runs as root and maps the active ID to its display name. Added the getActiveProfileName helper and removed the now-unused profilemanager import.

Manually verified: netbird up --profile <new-name> --setup-key <key> provisions and connects, and netbird status shows the correct profile name for both default and custom profiles.

https://github.com/netbirdio/netbird/discussions/6476 — regression report for netbird up --profile + setup-key failing on v0.73.0 after #6367.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

These are regression fixes that restore the documented pre-0.73.0 behavior of netbird up --profile and the netbird status output. No public CLI flags, API surface, or configuration options change, so existing documentation remains accurate.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved RPC error handling for profile-related operations, including clearer error wrapping during daemon failures.
  • New Features
    • The up command now switches to a specified profile, and if it doesn’t exist, creates it and then retries activation.
  • Improvements
    • The status command now pulls the active profile’s display name from the running daemon.
    • Profile creation output is more reliable by using the daemon-returned profile ID after creation.
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/6479 **State:** closed **Merged:** Yes --- ## Describe your changes PR #6367 (migrating profile identity from display name to ID) introduced two regressions in the CLI profile flow. This PR fixes both. 1. **`netbird up --profile <name>` no longer auto-created a missing profile.** Before #6367, switching to a non-existent profile name simply recorded it as the active profile and the config file was created lazily. After the migration, the daemon resolves the supplied handle against existing profiles and returns `codes.NotFound`, which broke ephemeral CI workflows relying on `netbird up --profile <name> --setup-key <key>` to provision the profile on the fly (reported in discussion #6476). `upFunc` in `client/cmd/up.go` now detects `codes.NotFound` from `switchProfile`, creates the profile via the daemon's existing `AddProfile` RPC (`createProfile` helper in `client/cmd/login.go`), and retries the switch. To make the status code inspectable by the caller, `switchProfile` now wraps the daemon error with `%w` instead of `%v`. 2. **`netbird status` showed an empty `Profile:` field** for both the default and custom profiles. After #6367, `ProfileManager.GetActiveProfile` returns only the profile ID (not the display name), and the CLI — running as the invoking user — cannot read the per-user profile files under `/var/lib/netbird/<user>/` (root-owned, `0700`) to resolve the name itself. `client/cmd/status.go` now resolves the display name through the daemon's existing `GetActiveProfile` RPC, which runs as root and maps the active ID to its display name. Added the `getActiveProfileName` helper and removed the now-unused `profilemanager` import. Manually verified: `netbird up --profile <new-name> --setup-key <key>` provisions and connects, and `netbird status` shows the correct profile name for both default and custom profiles. ## Issue ticket number and link https://github.com/netbirdio/netbird/discussions/6476 — regression report for `netbird up --profile` + setup-key failing on v0.73.0 after #6367. ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) These are regression fixes that restore the documented pre-0.73.0 behavior of `netbird up --profile` and the `netbird status` output. No public CLI flags, API surface, or configuration options change, so existing documentation remains accurate. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved RPC error handling for profile-related operations, including clearer error wrapping during daemon failures. * **New Features** * The `up` command now switches to a specified profile, and if it doesn’t exist, creates it and then retries activation. * **Improvements** * The `status` command now pulls the active profile’s display name from the running daemon. * Profile creation output is more reliable by using the daemon-returned profile ID after creation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
saavagebueno added the pull-request label 2026-08-05 08:06:08 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#28304