fix: remove db_owner requirement for allow_writes on MCP#376
Conversation
📝 WalkthroughWalkthroughThe PR removes validation logic that previously enforced ChangesRelaxed Connect-As Validation
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | -4 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/internal/api/apiv1/validate_test.go (1)
2101-2104: 💤 Low valueLGTM — assertion correctly reflects the removed db_owner enforcement.
The switch to
assert.Empty(t, errs)aligns exactly with the updatedvalidateConnectAsinvalidate.go(lines 409–423), which now returnsnilimmediately upon finding a matching username, without inspectingDbOwneror theallow_writesconfig key.One optional note: the
adminentry in thedbUsersfixture (line 2070) hasDbOwnerunset (nil) and is never directly exercised in a sub-test assertion. Adding a sub-test that usesadminwith an explicitDbOwner: utils.PointerTo(false)andallow_writes: truewould more precisely document the scenario described in the PR (a user withdb_owner: falsebut SUPERUSER attributes), and make the fixture entry purposeful.✨ Suggested additional sub-test
t.Run("non-owner with allow_writes", func(t *testing.T) { errs := validateConnectAs(baseSvc("app_read_only", true), dbUsers, nil) assert.Empty(t, errs) }) + + t.Run("explicit db_owner=false user with allow_writes", func(t *testing.T) { + errs := validateConnectAs(baseSvc("admin", true), dbUsers, nil) + assert.Empty(t, errs) + })And in the fixture, make the intent explicit:
- {Username: "admin"}, + {Username: "admin", DbOwner: utils.PointerTo(false)},🤖 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 `@server/internal/api/apiv1/validate_test.go` around lines 2101 - 2104, The test suite currently doesn't exercise the `admin` entry in the `dbUsers` fixture; add a focused sub-test that calls validateConnectAs with the `admin` user (from `dbUsers`) set to have DbOwner: utils.PointerTo(false) and run it with allow_writes true, asserting the result is empty (assert.Empty(t, errs)) to document the case "db_owner: false but SUPERUSER attributes" and make the fixture purposeful; locate this change near the existing sub-test that uses baseSvc("app_read_only", true) and the validateConnectAs call so the new sub-test mirrors that pattern and clearly references `validateConnectAs`, `dbUsers`, and the `admin` fixture entry.
🤖 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 `@server/internal/api/apiv1/validate_test.go`:
- Around line 2101-2104: The test suite currently doesn't exercise the `admin`
entry in the `dbUsers` fixture; add a focused sub-test that calls
validateConnectAs with the `admin` user (from `dbUsers`) set to have DbOwner:
utils.PointerTo(false) and run it with allow_writes true, asserting the result
is empty (assert.Empty(t, errs)) to document the case "db_owner: false but
SUPERUSER attributes" and make the fixture purposeful; locate this change near
the existing sub-test that uses baseSvc("app_read_only", true) and the
validateConnectAs call so the new sub-test mirrors that pattern and clearly
references `validateConnectAs`, `dbUsers`, and the `admin` fixture entry.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8cc2f21e-3854-4ceb-b965-4bb7aa6a2501
📒 Files selected for processing (2)
server/internal/api/apiv1/validate.goserver/internal/api/apiv1/validate_test.go
💤 Files with no reviewable changes (1)
- server/internal/api/apiv1/validate.go
Summary
This PR removes the validation that required
connect_asto reference adb_owner: trueuser whenallow_writes: trueis set on an MCP service. PostgreSQL enforces write permissions at query time — the control plane check was redundant and blocked valid configurations.Changes
db_ownerenforcement invalidateConnectAs()for MCPallow_writesallow_writes: trueTesting
Verification:
Before Fix:
After Fix:
Checklist
PLAT-587