[PR #6721] [management] fix: prevent group deletion when referenced by service access_groups #29832

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6721
Author: @CoderSufiyan
Created: 7/10/2026
Status: 🔄 Open

Base: mainHead: fix/issue-6637-group-deletion-service-check


📝 Commits (1)

  • b68783c [management] fix: prevent group deletion when referenced by service access_groups

📊 Changes

2 files changed (+46 additions, -0 deletions)

View changed files

📝 management/server/group.go (+22 -0)
📝 management/server/group_test.go (+24 -0)

📄 Description

Description

Groups can be deleted even when referenced in a private service's AccessGroups field, which orphans the group reference and compromises service access control.

Added isGroupLinkedToService check to validateDeleteGroup, consistent with existing checks for routes, policies, setup keys, and users.

Changes

  • group.go: Added isGroupLinkedToService() helper and its call in validateDeleteGroup(), following the exact same pattern as the existing 6 isGroupLinkedTo* functions
  • group_test.go: Added groupForService + a service with AccessGroups to the test setup, and a "service" test case

Verification

  • go build ./management/server/ — clean
  • go vet ./management/server/ — clean
  • go test -run "TestDefaultAccountManager_DeleteGroup" ./management/server/ -v9/9 PASS (8 existing + 1 new)

Fixes #6637

Summary by CodeRabbit

  • Bug Fixes
    • Prevented deletion of groups that are still linked to reverse proxy services.
    • Deletion validation now identifies the linked service when a group cannot be removed.

🔄 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/6721 **Author:** [@CoderSufiyan](https://github.com/CoderSufiyan) **Created:** 7/10/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/issue-6637-group-deletion-service-check` --- ### 📝 Commits (1) - [`b68783c`](https://github.com/netbirdio/netbird/commit/b68783c5f9615fab8d1d2d78b80a482973940fd3) [management] fix: prevent group deletion when referenced by service access_groups ### 📊 Changes **2 files changed** (+46 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `management/server/group.go` (+22 -0) 📝 `management/server/group_test.go` (+24 -0) </details> ### 📄 Description ## Description Groups can be deleted even when referenced in a private service's `AccessGroups` field, which orphans the group reference and compromises service access control. Added `isGroupLinkedToService` check to `validateDeleteGroup`, consistent with existing checks for routes, policies, setup keys, and users. ## Changes - **group.go**: Added `isGroupLinkedToService()` helper and its call in `validateDeleteGroup()`, following the exact same pattern as the existing 6 `isGroupLinkedTo*` functions - **group_test.go**: Added `groupForService` + a service with `AccessGroups` to the test setup, and a `"service"` test case ## Verification - `go build ./management/server/` — clean - `go vet ./management/server/` — clean - `go test -run "TestDefaultAccountManager_DeleteGroup" ./management/server/ -v` — **9/9 PASS** (8 existing + 1 new) Fixes #6637 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Prevented deletion of groups that are still linked to reverse proxy services. * Deletion validation now identifies the linked service when a group cannot be removed. <!-- 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 08:09:06 -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#29832