[PR #6367] [client] Migrate profile identity from display name to ID and allow renaming of profiles #28094

Closed
opened 2026-08-05 08:05:46 -04:00 by saavagebueno · 0 comments
Owner

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

State: closed
Merged: Yes


Describe your changes

This PR decouples a profile's identity from its display name. Previously the profile name was used for its on-disk config filename, forcing unique, character-restricted names. Now each profile has a stable ID (the filename) while the name is free-form and stored inside the profile JSON. New rpc and cli cmd are added for renaming of profiles.

Changes

  • IDs: new profiles get a generated 32-char hex ID, legacy profiles keep their name as their ID, so existing files keep working with no migration.

  • Resolution: handles resolve server-side by exact ID > unique ID prefix > unique name. Ambiguous handles return a typed error with candidates.

  • Validation: filename stems are guarded against path traversal and restricted charset (id.go). Display names are UTF-8-validated, control-char stripped, and length-capped.

  • gRPC: Profile, GetActiveProfileResponse, and the Add/Switch/Remove responses gain an additive id field (name retained for older clients). New RenameProfile rpc. profileNames in profile requests acts as handles instead of only profile names (backward compat).

  • CLI: profile list --show-id adds an ID column: select/remove accept name, ID, or unique prefix, with disambiguation help on ambiguity. profile rename` allows users to rename profiles, even the default one.
    image

  • UI: the tray client now keys profile operations (switch/remove/logout, config/login requests) on profile ID instead of name, logout confirmation still shows the display name. If there are multiple profiles with the same name, the id is added to the name to differentiate.

  • Android: profile manager updated to the ID model.

Compatibility: fully backward compatible with legacy profiles, existing state files, and older clients all keep working.

Tests: new service_test.go plus updates across profilemanager/server/cmd tests.
OS test: have done manual testing on linux, macos, windows and android as they all use the go implementation of profiles (ios uses a native swift implementation).

Related PR for android-client: https://github.com/netbirdio/android-client/pull/189

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)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

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)

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

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

https://github.com/netbirdio/docs/pull/781

Summary by CodeRabbit

Summary

  • New Features

    • Profiles now use stable, shortable IDs end-to-end; the CLI can optionally display IDs with profile list --show-id.
    • Added netbird profile rename command.
    • Profile switch/add/remove operations now show the resolved (short) profile ID.
  • Bug Fixes

    • Improved profile resolution and disambiguation when handles/names are ambiguous.
    • Updated login, logout, and config flows to reliably target the active profile by ID.
    • Enhanced Android/UI profile selection to operate on IDs.
  • Tests

    • Updated and expanded coverage for ID-based profile lifecycle and validation.
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/6367 **State:** closed **Merged:** Yes --- ## Describe your changes This PR decouples a profile's identity from its display name. Previously the profile name was used for its on-disk config filename, forcing unique, character-restricted names. Now each profile has a stable ID (the filename) while the name is free-form and stored inside the profile JSON. New rpc and cli cmd are added for renaming of profiles. Changes - IDs: new profiles get a generated 32-char hex ID, legacy profiles keep their name as their ID, so existing files keep working with no migration. - Resolution: handles resolve server-side by exact ID > unique ID prefix > unique name. Ambiguous handles return a typed error with candidates. - Validation: filename stems are guarded against path traversal and restricted charset (id.go). Display names are UTF-8-validated, control-char stripped, and length-capped. - gRPC: `Profile`, `GetActiveProfileResponse`, and the `Add`/`Switch`/`Remove` responses gain an additive id field (name retained for older clients). New `RenameProfile` rpc. `profileNames` in profile requests acts as handles instead of only profile names (backward compat). - CLI: `profile list --show-id adds an ID column: select/remove accept name, ID, or unique prefix, with disambiguation help on ambiguity. `profile rename` allows users to rename profiles, even the default one. <img width="1074" height="889" alt="image" src="https://github.com/user-attachments/assets/2fef50f5-97b1-4863-b1ea-0bf038c3c20a" /> - UI: the tray client now keys profile operations (switch/remove/logout, config/login requests) on profile ID instead of name, logout confirmation still shows the display name. If there are multiple profiles with the same name, the id is added to the name to differentiate. - Android: profile manager updated to the ID model. Compatibility: fully backward compatible with legacy profiles, existing state files, and older clients all keep working. Tests: new service_test.go plus updates across profilemanager/server/cmd tests. OS test: have done manual testing on linux, macos, windows and android as they all use the go implementation of profiles (ios uses a native swift implementation). Related PR for android-client: https://github.com/netbirdio/android-client/pull/189 ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) - [x] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > 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: - [x] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/781 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary * **New Features** * Profiles now use stable, shortable IDs end-to-end; the CLI can optionally display IDs with `profile list --show-id`. * Added `netbird profile rename` command. * Profile switch/add/remove operations now show the resolved (short) profile ID. * **Bug Fixes** * Improved profile resolution and disambiguation when handles/names are ambiguous. * Updated login, logout, and config flows to reliably target the active profile by ID. * Enhanced Android/UI profile selection to operate on IDs. * **Tests** * Updated and expanded coverage for ID-based profile lifecycle and validation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
saavagebueno added the pull-request label 2026-08-05 08:05:46 -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#28094