[PR #6416] [management] Fix broken self-hosted automated setup #25680

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6416
Author: @sm9000
Created: 6/12/2026
Status: 🔄 Open

Base: mainHead: patch-1


📝 Commits (1)

  • e4b1696 [management] Fix broken self-hosted automated setup

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 management/server/instance/setup_service.go (+1 -1)

📄 Description

Describe your changes

Currently, the self-hosted server with NB_SETUP_PAT_ENABLED=true creates a (seemingly) broken accounts table in the database after calling /api/setup:

sqlite> SELECT id, domain, domain_category, is_domain_primary_account, created_by FROM accounts;
┌──────────────────────┬────────┬─────────────────┬───────────────────────────┬──────────────────────────────────────────────────────────────┐
│          id          │ domain │ domain_category │ is_domain_primary_account │                          created_by                          │
├──────────────────────┼────────┼─────────────────┼───────────────────────────┼──────────────────────────────────────────────────────────────┤
│ d8cpomhtooqc73e..... │        │                 │ 0                         │ CiQ4ODQyZTZlMy03M2FkLTQ2OWEtYjhjNi01NmMxYjFjYjZlOD.......... │
└──────────────────────┴────────┴─────────────────┴───────────────────────────┴──────────────────────────────────────────────────────────────┘

This caused users signing in using SSO to get the "Owner" role for their own account, and cannot reach resources in the original network as expected.

With this fix (as well as after doing the setup in the web UI), enrolling clients using SSO works as expected. And the accounts table looks better:

sqlite> SELECT id, domain, domain_category, is_domain_primary_account, created_by FROM accounts;
┌──────────────────────┬────────────────────┬─────────────────┬───────────────────────────┬──────────────────────────────────────────────────────────────┐
│          id          │       domain       │ domain_category │ is_domain_primary_account │                          created_by                          │
├──────────────────────┼────────────────────┼─────────────────┼───────────────────────────┼──────────────────────────────────────────────────────────────┤
│ d8cpj8gds6bc739..... │ netbird.selfhosted │ private         │ 1                         │ CiQxOTA2OGE0Ni0wODk0LTQwMDctYWJhNi1lY2RhZDBiZT.............. │
└──────────────────────┴────────────────────┴─────────────────┴───────────────────────────┴──────────────────────────────────────────────────────────────┘

I'm not very familiar with the netbird code base and application. As such, it is possible this change could have side effects I'm not aware of.

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)

Summary by CodeRabbit

  • Bug Fixes
    • Improved account setup reliability by refining the account lookup mechanism during owner account provisioning.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6416 **Author:** [@sm9000](https://github.com/sm9000) **Created:** 6/12/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`e4b1696`](https://github.com/netbirdio/netbird/commit/e4b16965f514020e5702397a0b2dbca82ccd75e2) [management] Fix broken self-hosted automated setup ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `management/server/instance/setup_service.go` (+1 -1) </details> ### 📄 Description ## Describe your changes Currently, the self-hosted server with `NB_SETUP_PAT_ENABLED=true` creates a (seemingly) broken `accounts` table in the database after calling `/api/setup`: ``` sqlite> SELECT id, domain, domain_category, is_domain_primary_account, created_by FROM accounts; ┌──────────────────────┬────────┬─────────────────┬───────────────────────────┬──────────────────────────────────────────────────────────────┐ │ id │ domain │ domain_category │ is_domain_primary_account │ created_by │ ├──────────────────────┼────────┼─────────────────┼───────────────────────────┼──────────────────────────────────────────────────────────────┤ │ d8cpomhtooqc73e..... │ │ │ 0 │ CiQ4ODQyZTZlMy03M2FkLTQ2OWEtYjhjNi01NmMxYjFjYjZlOD.......... │ └──────────────────────┴────────┴─────────────────┴───────────────────────────┴──────────────────────────────────────────────────────────────┘ ``` This caused users signing in using SSO to get the "Owner" role for their own account, and cannot reach resources in the original network as expected. With this fix (as well as after doing the setup in the web UI), enrolling clients using SSO works as expected. And the accounts table looks better: ``` sqlite> SELECT id, domain, domain_category, is_domain_primary_account, created_by FROM accounts; ┌──────────────────────┬────────────────────┬─────────────────┬───────────────────────────┬──────────────────────────────────────────────────────────────┐ │ id │ domain │ domain_category │ is_domain_primary_account │ created_by │ ├──────────────────────┼────────────────────┼─────────────────┼───────────────────────────┼──────────────────────────────────────────────────────────────┤ │ d8cpj8gds6bc739..... │ netbird.selfhosted │ private │ 1 │ CiQxOTA2OGE0Ni0wODk0LTQwMDctYWJhNi1lY2RhZDBiZT.............. │ └──────────────────────┴────────────────────┴─────────────────┴───────────────────────────┴──────────────────────────────────────────────────────────────┘ ``` I'm not very familiar with the netbird code base and application. As such, it is possible this change could have side effects I'm not aware of. ### 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) - [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: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved account setup reliability by refining the account lookup mechanism during owner account provisioning. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:06:19 -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#25680