Skip to content

fix(explore): hide Superset annotation source for users without annotation access - #43006

Open
endimonan wants to merge 2 commits into
apache:masterfrom
endimonan:fix/hide-native-annotation-source-34904
Open

fix(explore): hide Superset annotation source for users without annotation access#43006
endimonan wants to merge 2 commits into
apache:masterfrom
endimonan:fix/hide-native-annotation-source-34904

Conversation

@endimonan

@endimonan endimonan commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

Fixes #34904. A Gamma user can create a chart but has no can_read on Annotation (intentional since #24826), so when they picked the "Superset annotation" source in the annotation layer popover, the layer dropdown fetched /api/v1/annotation_layer/, got a 403 and rendered a raw "Forbidden" message as if it were content.

This hides the "Superset annotation" option from the annotation source select when the user doesn't hold the permission, which is the same approach #34293 took for the "View in SQL Lab" button in the same directory. The permission is computed in the connected control via findPermission('can_read', 'Annotation', user.roles), mirroring the API gate, and passed down as a prop. mapStateToProps is exported so the permission wiring itself is unit tested, since a missing state prop would silently fall through to untyped ownProps and hide the option for everyone.

One special case: a chart may already have a saved native annotation layer, and those keep rendering for viewers today. For that case the source option stays visible so the saved configuration isn't invalidated, but the layer selector renders disabled with "You don't have permission to view annotation layers." and the known-forbidden requests (the listing and the fetch by id) are never fired. The user can still remove the layer, tweak its display settings or switch it to a chart-based source, and re-applying preserves the saved reference as is. Once switched away, the native option is gone.

Formula and chart-based annotation sources don't touch the annotation API and are unaffected. The fetch of the applied native layer also gains a catch handler, it used to be an unhandled promise rejection.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before (Gamma user): picking the "Superset annotation" source ends in a raw Forbidden error inside the layer dropdown.
before

After (same Gamma user): the source select no longer offers "Superset annotation" and chart sources keep working.
after

Admins keep the option.
admin

TESTING INSTRUCTIONS

As a Gamma user (no can_read on Annotation), open a line chart in Explore, add an annotation layer of type Event or Interval and open the "Annotation source" select: "Superset annotation" should not be listed, while chart sources and Formula keep working. As Admin, the option is still there. To check the preserved case, have an Admin save a chart with a native annotation layer, then open it as Gamma: the layer still renders on the chart, and in the popover the source shows "Superset annotation" with the layer selector disabled and a permission note instead of the old Forbidden error.

ADDITIONAL INFORMATION

  • Has associated issue: Fixes Gamma user can't list annotation #34904
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

The annotation layer popover offered the "Superset annotation" source to
everyone, but listing native annotation layers requires can_read on
Annotation, which Gamma users don't have by default. The result was a raw
"Forbidden" message inside the layer dropdown after several clicks (apache#34904).

The option is now only offered when the user holds the permission, the same
approach apache#34293 took for the SQL Lab button in ViewQuery. A layer that was
already saved with the native source keeps the option visible so the saved
configuration stays intact, but its layer selector is disabled with a short
explanation and the known-forbidden requests are skipped entirely. Formula
and chart-based annotations are unaffected. The applied-layer fetch also
gains a catch handler, it used to be an unhandled rejection.
@netlify

netlify Bot commented Aug 10, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 0232e9d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7a1ef6eb29f90007e6892b
😎 Deploy Preview https://deploy-preview-43006--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.42%. Comparing base (916c502) to head (2ef98ea).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43006      +/-   ##
==========================================
+ Coverage   66.41%   66.42%   +0.01%     
==========================================
  Files        2858     2858              
  Lines      161446   161455       +9     
  Branches    37190    37197       +7     
==========================================
+ Hits       107222   107246      +24     
+ Misses      52187    52172      -15     
  Partials     2037     2037              
Flag Coverage Δ
javascript 73.29% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@endimonan
endimonan marked this pull request as ready for review August 10, 2026 18:56
@dosubot dosubot Bot added authentication:access-control Rlated to access control change:frontend Requires changing the frontend explore:annotation Related to annotations in Explore labels Aug 10, 2026
@rusackas
rusackas requested review from EnxDev and rusackas and removed request for rusackas August 10, 2026 19:50
@bito-code-review

bito-code-review Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1cebc0

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: 2ef98ea..0232e9d
    • superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.subdirectory.test.tsx
    • superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.test.tsx
    • superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.tsx
    • superset-frontend/src/explore/components/controls/AnnotationLayerControl/index.test.tsx
    • superset-frontend/src/explore/components/controls/AnnotationLayerControl/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

authentication:access-control Rlated to access control change:frontend Requires changing the frontend explore:annotation Related to annotations in Explore size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gamma user can't list annotation

2 participants