[management] require dashboard_features.agent_network when enabling agent_network_only#6750
Conversation
…gent_network_only
|
📝 WalkthroughWalkthroughThe account settings handler now rejects ChangesAgent network settings
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
management/server/http/handlers/accounts/accounts_handler_test.go (1)
318-326: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winConsider adding edge-case test coverage.
The negative test covers the "no
dashboard_features" case. Two additional scenarios would strengthen coverage:
agent_network_only: truewithdashboard_features: {agent_network: false}— should also return 422.agent_network_only: truewithdashboard_features: {}(empty object,agent_networkomitted) — should also return 422 sinceAgentNetworkwould be nil.These exercise the
!*returnSettings.DashboardFeatures.AgentNetworkandreturnSettings.DashboardFeatures.AgentNetwork == nilbranches 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
📒 Files selected for processing (4)
management/server/http/handlers/accounts/accounts_handler.gomanagement/server/http/handlers/accounts/accounts_handler_test.goshared/management/http/api/openapi.ymlshared/management/http/api/types.gen.go
Release artifactsBuilt for PR head
GHCR images (amd64)
This comment is updated by the Release workflow. Artifact links expire according to the workflow retention policy. |



Describe your changes
Adds a settings constraint: enabling
agent_network_onlyrequiresdashboard_features.agent_networkto betruein 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
updateAccountRequestSettingsagainst the parsed request state: if the resulting settings haveagent_network_only == truebutdashboard_features.agent_networkis nottrue, the update is rejected withstatus.InvalidArgument(HTTP 422) before anything is persisted.The OpenAPI field descriptions for
agent_network_onlyanddashboard_features.agent_networkdocument the requirement. Only the descriptions changed —requiredand the schema$refare untouched — andtypes.gen.gowas 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
Documentation
Select exactly one:
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
agent_network_onlyunless thedashboard_features.agent_networkfeature is explicitly provided and enabled.422 Unprocessable Entityresponse instead of being accepted.Documentation
agent_network_onlyand theagent_networkdashboard feature.