Add PostgreSQL role and grant management specification#437
Closed
pyramation wants to merge 1 commit into
Closed
Conversation
Document the patterns and requirements for creating, granting, and managing PostgreSQL roles and users to address race conditions, idempotency, and SQL safety concerns. Key patterns documented: - CREATE ROLE with pre-existence check, advisory lock, and dual exception handling - GRANT role membership with pre-existence check and exception handling - REVOKE/DROP ROLE with proper identifier quoting Lists all affected code paths and specific issues to fix in main branch. Co-Authored-By: Dan Lynch <pyramation@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add PostgreSQL role and grant management specification
Summary
Adds a SPEC.md document that specifies patterns and requirements for creating, granting, and managing PostgreSQL roles and users. This specification addresses race conditions, idempotency, and SQL safety concerns identified in the current implementation (related to PR #325).
The document covers:
This is a documentation-only PR with no code changes. The spec is intended to guide future implementation work to fix the identified issues.
Review & Testing Checklist for Human
pg_advisory_xact_lock(42, hashtext(...))and the dual exception handling (duplicate_object OR unique_violation)CREATE ROLE,CREATE USER,GRANT,REVOKE,DROP ROLEstatements that may have been missedremoveDbRoles()(lines 139-141 of client.ts) - verify that${username}interpolation withoutformat('%I', ...)is actually a risk given the upstream sanitizationNotes
42was chosen arbitrarily since no other advisory locks currently exist in the codebase. Consider if a different convention is preferred.Link to Devin run: https://app.devin.ai/sessions/94c39fc3c7184ff6b799f00bb5d17782
Requested by: Dan Lynch (pyramation@gmail.com) / @pyramation