Skip to content

[management] require dashboard_features.agent_network when enabling agent_network_only#6750

Merged
mlsmaycon merged 1 commit into
mainfrom
feature/agent-network-only-dashboard-constraint
Jul 13, 2026
Merged

[management] require dashboard_features.agent_network when enabling agent_network_only#6750
mlsmaycon merged 1 commit into
mainfrom
feature/agent-network-only-dashboard-constraint

Conversation

@mlsmaycon

@mlsmaycon mlsmaycon commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes

Adds a settings constraint: enabling agent_network_only requires dashboard_features.agent_network to be true in the same account update. Without the Agent Network menu flag, a focused account that later turns the focused view off would lose access to the Agent Network menu entirely, so the two must be set together.

The check runs in updateAccountRequestSettings against the parsed request state: if the resulting settings have agent_network_only == true but dashboard_features.agent_network is not true, the update is rejected with status.InvalidArgument (HTTP 422) before anything is persisted.

The OpenAPI field descriptions for agent_network_only and dashboard_features.agent_network document the requirement. Only the descriptions changed — required and the schema $ref are untouched — and types.gen.go was regenerated from the spec (diff is the two comment lines).

Issue ticket number and link

N/A — follow-up to #6742 (dashboard_features setting) and the dashboard signup flow.

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)

The generated API reference picks up the updated OpenAPI field descriptions automatically; there is no separate user-facing doc for this account setting.

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/__

Summary by CodeRabbit

  • Bug Fixes

    • Account settings now reject enabling agent_network_only unless the dashboard_features.agent_network feature is explicitly provided and enabled.
    • Invalid configurations return a clear 422 Unprocessable Entity response instead of being accepted.
  • Documentation

    • Updated account settings documentation to explain the required relationship between agent_network_only and the agent_network dashboard feature.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The account settings handler now rejects agent_network_only unless dashboard_features.agent_network is enabled. Handler tests cover valid and invalid requests, and API documentation describes the dependency.

Changes

Agent network settings

Layer / File(s) Summary
Document the setting dependency
shared/management/http/api/openapi.yml, shared/management/http/api/types.gen.go
API descriptions and generated comments state that agent_network_only requires the agent_network dashboard feature.
Validate account setting updates
management/server/http/handlers/accounts/accounts_handler.go, management/server/http/handlers/accounts/accounts_handler_test.go
Settings updates reject missing or disabled dashboard_features.agent_network, while valid requests and the resulting settings are tested.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main behavior change: requiring dashboard_features.agent_network when agent_network_only is enabled.
Description check ✅ Passed The description matches the template sections and includes changes, issue link, checklist, and documentation selection.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/agent-network-only-dashboard-constraint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
management/server/http/handlers/accounts/accounts_handler_test.go (1)

318-326: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Consider adding edge-case test coverage.

The negative test covers the "no dashboard_features" case. Two additional scenarios would strengthen coverage:

  • agent_network_only: true with dashboard_features: {agent_network: false} — should also return 422.
  • agent_network_only: true with dashboard_features: {} (empty object, agent_network omitted) — should also return 422 since AgentNetwork would be nil.

These exercise the !*returnSettings.DashboardFeatures.AgentNetwork and returnSettings.DashboardFeatures.AgentNetwork == nil branches respectively.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@management/server/http/handlers/accounts/accounts_handler_test.go` around
lines 318 - 326, The PutAccount negative-test cases should also cover
agent_network_only enabled with dashboard_features.agent_network explicitly
false and with an empty dashboard_features object. Add separate requests
asserting HTTP 422, exercising the false-value and nil AgentNetwork branches
while preserving the existing no-dashboard_features case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@management/server/http/handlers/accounts/accounts_handler_test.go`:
- Around line 318-326: The PutAccount negative-test cases should also cover
agent_network_only enabled with dashboard_features.agent_network explicitly
false and with an empty dashboard_features object. Add separate requests
asserting HTTP 422, exercising the false-value and nil AgentNetwork branches
while preserving the existing no-dashboard_features case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c30dfcdd-0ea2-4007-ab57-77078519af02

📥 Commits

Reviewing files that changed from the base of the PR and between 8f64173 and 1d6c829.

📒 Files selected for processing (4)
  • management/server/http/handlers/accounts/accounts_handler.go
  • management/server/http/handlers/accounts/accounts_handler_test.go
  • shared/management/http/api/openapi.yml
  • shared/management/http/api/types.gen.go

@braginini braginini self-requested a review July 13, 2026 15:12
@github-actions

Copy link
Copy Markdown

Release artifacts

Built for PR head 1d6c829 in workflow run #16678.

Artifact Link
All release artifacts Download
Linux packages Download
Windows packages Download
macOS packages Download
UI artifacts Download
UI macOS artifacts Download

GHCR images (amd64)

This comment is updated by the Release workflow. Artifact links expire according to the workflow retention policy.

@mlsmaycon mlsmaycon merged commit 831325d into main Jul 13, 2026
47 checks passed
@mlsmaycon mlsmaycon deleted the feature/agent-network-only-dashboard-constraint branch July 13, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants