← Back to Pull requests

fix: name the denied resource in SQL forbidden errors #20980

Open
unknown opened this pull request with 228 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 30, 2026 04:57 UTC
Author

Description

A denied SQL query does not say which permission is missing, so neither the user nor the admin knows what to grant.

Before:

Unauthorized

After:

Unauthorized: user[frank] has no WRITE permission on resource type[DATASOURCE] name[wikipedia] in authorizer[basic]. Ask your administrator to grant this permission to you or your roles.

Release note

The 403 error for a denied SQL query now names the missing permission, for example Unauthorized: user[frank] has no WRITE permission on resource type[DATASOURCE] name[wikipedia] in authorizer[basic]. ....
This applies to /druid/v2/sql, JDBC, /druid/v2/sql/task and /druid/v2/sql/statements.
Clients that compare the error to the exact string Unauthorized need to match on the Unauthorized prefix instead.
With druid.server.http.errorResponseTransform.strategy=allowedRegex, the detail is shown only if it matches an allowed regex; otherwise the authorizer's own message is shown if it matches, and Unauthorized if not.
Previously the authorizer's own message reached SQL clients without this check.

Security

Only SQL denials name the resource, since every resource the planner checks comes from the query itself.
REST resource filters still return Unauthorized, because they check resources the caller did not send, such as a task's datasource.
Tables the caller cannot read are still reported as not found (druid.sql.planner.authorizeTableVisibility).

<hr>

This PR has:

  • been self-reviewed.

  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.

  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • Diff: 228 lines (+171 / -57) across 2 files Reviewer: FrankChen021 Review duration: 1610m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 228 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.325
    Real PR Conversation Timeline
    1 comments
    "Review active on #20980"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.0% (MEDIUM) · Higher = larger blast radius
    37.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.1% · Safe to merge
    21.1%
    Repository