fix(updater): network restrictions not enabled#4887
Conversation
## Summary Mitigates workflow failures caused by `400` responses from network restrictions endpoints when projects are not entitled to manage restrictions and local config has `db.network_restrictions.enabled = false` or not set. The fix ensures we only read/update network restrictions when local config explicitly enables the feature, while preserving strict failure behavior when it is enabled.
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThe changes add an optimization to the Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/config/updater_test.go (1)
334-398:⚠️ Potential issue | 🔴 Critical
TestUpdateRemoteConfigwill fail — unconsumed gock mock for network restrictions.The
dbvalue passed toUpdateRemoteConfig(lines 370-374) leavesNetworkRestrictionsat its zero value, soEnabled == false. With the new early return inUpdateDbNetworkRestrictionsConfig, the GET/v1/projects/test-project/network-restrictionsrequest is never made. The gock mock registered at lines 334-338 is never consumed, sogock.IsDone()(line 397) returnsfalseand the assertion fails.Remove the unconsumed mock (simplest fix):
🐛 Proposed fix
- // Network config - gock.New(server). - Get("/v1/projects/test-project/network-restrictions"). - Reply(http.StatusOK). - JSON(v1API.V1GetNetworkRestrictionsResponse{})Or, if the test should also cover the network-restrictions update path, set
Enabled: trueon the db config:Db: db{ Settings: settings{ MaxConnections: cast.Ptr(cast.IntToUint(100)), }, + NetworkRestrictions: networkRestrictions{ + Enabled: true, + }, },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/config/updater_test.go` around lines 334 - 398, TestUpdateRemoteConfig fails because an unused gock mock for GET /v1/projects/test-project/network-restrictions is registered but UpdateDbNetworkRestrictionsConfig now early-returns when NetworkRestrictions.Enabled is false; either remove the gock.New(...).Get("/v1/projects/test-project/network-restrictions") mock from the test or change the test input passed into UpdateRemoteConfig so db.Settings.NetworkRestrictions.Enabled = true (i.e., set the NetworkRestrictions struct on the db/settings in the baseConfig) so the network-restrictions path is exercised and the mock is consumed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@pkg/config/updater_test.go`:
- Around line 334-398: TestUpdateRemoteConfig fails because an unused gock mock
for GET /v1/projects/test-project/network-restrictions is registered but
UpdateDbNetworkRestrictionsConfig now early-returns when
NetworkRestrictions.Enabled is false; either remove the
gock.New(...).Get("/v1/projects/test-project/network-restrictions") mock from
the test or change the test input passed into UpdateRemoteConfig so
db.Settings.NetworkRestrictions.Enabled = true (i.e., set the
NetworkRestrictions struct on the db/settings in the baseConfig) so the
network-restrictions path is exercised and the mock is consumed.
ℹ️ Review info
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Cache: Disabled due to Reviews > Disable Cache setting
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
pkg/config/updater.gopkg/config/updater_test.go
Pull Request Test Coverage Report for Build 22321003063Details
💛 - Coveralls |
Summary
Mitigates workflow failures caused by
400responses from network restrictions endpoints when projects are not entitled to manage restrictions and local config hasdb.network_restrictions.enabled = falseor not set.The fix ensures we only read/update network restrictions when local config explicitly enables the feature, while preserving strict failure behavior when it is enabled.