rbac: improve permission denied error messages#35880
Open
maheshwarip wants to merge 1 commit intomainfrom
Open
rbac: improve permission denied error messages#35880maheshwarip wants to merge 1 commit intomainfrom
maheshwarip wants to merge 1 commit intomainfrom
Conversation
Enhance permission denied error messages to provide more actionable
information to users:
1. Direct errors (role lacks privileges on an object):
- Show which role needs which privileges
- Show who owns the object
- Provide HINT with suggested GRANT command
2. Indirect errors (MV/view owner lacks privileges on dependency):
- Explain the dependency relationship
- Show which object in the lineage is causing the problem
- Provide HINT targeting the correct role (the owner who needs access)
Example direct error:
ERROR: permission denied for TABLE "schema.my_table"
DETAIL: The 'user1' role needs SELECT privileges on TABLE "schema.my_table"
The owner of TABLE "schema.my_table" is 'user2'
HINT: The owner ('user2') of TABLE "schema.my_table" or a superuser
can grant access: GRANT SELECT ON TABLE "schema.my_table" TO 'user1'
Example indirect error (querying an MV where owner lost access to dependency):
ERROR: permission denied for TABLE "schema.source_table"
DETAIL: The 'mv_owner' role needs SELECT privileges on TABLE "schema.source_table"
The owner of TABLE "schema.source_table" is 'source_owner'
MATERIALIZED VIEW "schema.my_mv" references TABLE "schema.source_table"
HINT: The owner ('source_owner') of TABLE "schema.source_table" or a superuser
can grant access: GRANT SELECT ON TABLE "schema.source_table" TO 'mv_owner'
Related to discussion:
https://materializeinc.slack.com/archives/CU7ELJ6E9/p1775481281751919
https://claude.ai/code/session_01FLZQqa7mRprzCTQT6oQ3Ss
Contributor
|
Thanks for opening this PR! Here are a few tips to help make the review process smooth for everyone. PR title guidelines
Pre-merge checklist
|
Contributor
Author
|
There's a chance this is slop - I'm not familiar with this part of our repo! At a glance, if this is wrong, feel free to just close the PR |
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.
Summary
Improves "permission denied" error messages to provide more actionable information to users:
Direct errors (role lacks privileges on an object):
Indirect errors (MV/view owner lacks privileges on dependency):
Example - Direct Error
Example - Indirect Error (querying MV where owner lost access to dependency)
Motivation
Users encountering permission denied errors often don't know:
This PR addresses all three by enriching error messages with owner information and actionable HINT suggestions.
Test plan
bin/sqllogictest -- test/sqllogictest/permission_denied_errors.sltbin/sqllogictest -- --rewrite-results test/sqllogictest/privilege_checks.sltto update remaining tests for new error formatRelated
Slack thread: https://materializeinc.slack.com/archives/CU7ELJ6E9/p1775481281751919
https://claude.ai/code/session_01FLZQqa7mRprzCTQT6oQ3Ss