Update user permissions error message#91
Merged
Conversation
AarushiShah-db
left a comment
Collaborator
There was a problem hiding this comment.
can you add a unit test for this please, ty!
AarushiShah-db
approved these changes
May 27, 2026
Collaborator
|
@asujithan can you rebase onto latest master, the e2e should pass now! good to merge after the tests pass |
bcbae56 to
9615424
Compare
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.
Catch ServerOperationError from the SQL connector inside run_usage_query and, when the error indicates the caller can't read system.ai_gateway.usage, raise a one-line actionable RuntimeError ("Ask your workspace admin to enable READ access to system.ai_gateway.usage for your account") instead of the raw [INSUFFICIENT_PERMISSIONS] ... SQLSTATE: 42501 text the connector emits. Previously ucode usage surfaced the unmodified connector message, which named the failure but not what to do about it.
Add a private _is_usage_table_access_error helper that lowercases the error string, strips backticks, square brackets, and single/double quotes, and returns True iff the result contains both system.ai_gateway and insufficient_permissions. The quote-stripping collapses identifier-quoting variants the connector may emit (
system.ai_gateway.usage, [system].[ai_gateway].[usage], 'system.ai_gateway.usage') to one canonical form. Matching the system.ai_gateway prefix rather than the full system.ai_gateway.usage is deliberate: schema-level denials (USE SCHEMA on system.ai_gateway) never name .usage in the error, but are still effectively the same problem from the user's perspective. Permission errors on unrelated catalogs/tables fall through unchanged to the existing Usage query failed.Test Plan
system.ai_gateway.usage), bracketed ([system].[ai_gateway].[usage]), and single-quoted ('system.ai_gateway.usage') forms each route to the friendly message.