You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "dpgaspar (via GitHub)" <gi...@apache.org> on 2025/10/06 12:21:55 UTC

[PR] fix: update chart with dashboards validation [superset]

dpgaspar opened a new pull request, #35523:
URL: https://github.com/apache/superset/pull/35523

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: update chart with dashboards validation [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #35523:
URL: https://github.com/apache/superset/pull/35523#issuecomment-3371400620

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/35523?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `15.38462%` with `11 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 50.74%. Comparing base ([`d39c55e`](https://app.codecov.io/gh/apache/superset/commit/d39c55e9413d394b0ef684f568449da0a9899c61?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`99ce342`](https://app.codecov.io/gh/apache/superset/commit/99ce34263d0db6edd2093c2a3871266b11e85b2b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/35523?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/commands/chart/update.py](https://app.codecov.io/gh/apache/superset/pull/35523?src=pr&el=tree&filepath=superset%2Fcommands%2Fchart%2Fupdate.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvY2hhcnQvdXBkYXRlLnB5) | 15.38% | [11 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/35523?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #35523       +/-   ##
   ===========================================
   + Coverage        0   50.74%   +50.74%     
   ===========================================
     Files           0      589      +589     
     Lines           0    43585    +43585     
     Branches        0     4716     +4716     
   ===========================================
   + Hits            0    22118    +22118     
   - Misses          0    20846    +20846     
   - Partials        0      621      +621     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/35523/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Ξ” | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/35523/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `46.28% <15.38%> (?)` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/35523/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `49.99% <15.38%> (?)` | |
   | [python](https://app.codecov.io/gh/apache/superset/pull/35523/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `50.74% <15.38%> (?)` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/35523/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ΓΈ> (?)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/35523?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: update chart with dashboards validation [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #35523:
URL: https://github.com/apache/superset/pull/35523#discussion_r2406046389


##########
superset/commands/chart/update.py:
##########
@@ -71,6 +72,28 @@ def run(self) -> Model:
 
         return ChartDAO.update(self._model, self._properties)
 
+    def _validate_new_dashboard_access(
+        self, requested_dashboards: list[Dashboard], exceptions: list[Exception]
+    ) -> None:
+        """
+        Validate user has access to any NEW dashboard relationships.
+        Existing relationships are preserved to maintain chart ownership rights.
+        """
+        if not self._model:
+            return
+
+        existing_dashboard_ids = {d.id for d in self._model.dashboards}
+        requested_dashboard_ids = {d.id for d in requested_dashboards}
+
+        if new_dashboard_ids := requested_dashboard_ids - existing_dashboard_ids:
+            # For NEW dashboard relationships, verify user has access
+            accessible_dashboards = DashboardDAO.find_by_ids(list(new_dashboard_ids))
+            accessible_dashboard_ids = {d.id for d in accessible_dashboards}
+            unauthorized_dashboard_ids = new_dashboard_ids - accessible_dashboard_ids

Review Comment:
   ### Redundant access validation for non-existent dashboards <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The access validation logic incorrectly assumes that if a dashboard is not returned by DashboardDAO.find_by_ids(), the user lacks access to it, when it could simply mean the dashboard doesn't exist.
   
   
   ###### Why this matters
   This creates a confusing user experience where attempting to add a non-existent dashboard to a chart results in a DashboardsNotFoundValidationError being raised twice - once for the existence check and once for the access check, even though the real issue is that the dashboard doesn't exist at all.
   
   ###### Suggested change βˆ™ *Feature Preview*
   Remove the redundant access validation since the existence check already handles non-existent dashboards. The `_validate_new_dashboard_access` method should only be called after confirming all dashboards exist:
   
   ```python
   def _validate_new_dashboard_access(
       self, requested_dashboards: list[Dashboard], exceptions: list[Exception]
   ) -> None:
       """
       Validate user has access to any NEW dashboard relationships.
       Existing relationships are preserved to maintain chart ownership rights.
       """
       if not self._model:
           return
   
       existing_dashboard_ids = {d.id for d in self._model.dashboards}
       requested_dashboard_ids = {d.id for d in requested_dashboards}
   
       if new_dashboard_ids := requested_dashboard_ids - existing_dashboard_ids:
           # For NEW dashboard relationships, verify user has access
           # Note: All dashboards are guaranteed to exist at this point
           accessible_dashboards = DashboardDAO.find_by_ids(list(new_dashboard_ids))
           accessible_dashboard_ids = {d.id for d in accessible_dashboards}
           unauthorized_dashboard_ids = new_dashboard_ids - accessible_dashboard_ids
   
           if unauthorized_dashboard_ids:
               exceptions.append(DashboardForbiddenError())  # Use appropriate access error
   ```
   
   And modify the validation flow:
   
   ```python
   if dashboard_ids is not None:
       # First, verify all requested dashboards exist
       dashboards = DashboardDAO.find_by_ids(
           dashboard_ids,
           skip_base_filter=True,
       )
       if len(dashboards) != len(dashboard_ids):
           exceptions.append(DashboardsNotFoundValidationError())
       else:
           # Only validate access if all dashboards exist
           self._validate_new_dashboard_access(dashboards, exceptions)
       self._properties["dashboards"] = dashboards
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/πŸ‘%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/cc548e1b-486b-4ca9-9692-2c9323d9d3bb/upvote) [![Incorrect](https://img.shields.io/badge/πŸ‘Ž%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/cc548e1b-486b-4ca9-9692-2c9323d9d3bb?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/πŸ‘Ž%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/cc548e1b-486b-4ca9-9692-2c9323d9d3bb?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/πŸ‘Ž%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/cc548e1b-486b-4ca9-9692-2c9323d9d3bb?what_not_in_standard=true) [![Other](https://img.shields.io/badge/πŸ‘Ž%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/cc548e1b-486b-4ca9-9692-2c9323d9d3bb)
   </details>
   
   <sub>
   
   πŸ’¬ Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:58c964c6-63de-4487-997c-bd2ea59d5232 -->
   
   
   [](58c964c6-63de-4487-997c-bd2ea59d5232)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: update chart with dashboards validation [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on PR #35523:
URL: https://github.com/apache/superset/pull/35523#issuecomment-3371373591

   Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment `/korbit-review`.
   
   > Your admin can change your review schedule in the [Korbit Console](https://app.korbit.ai/settings)
   
   
   
   [](9883f9be-cab1-4750-b09b-9197a7824501)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: update chart with dashboards validation [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #35523:
URL: https://github.com/apache/superset/pull/35523#issuecomment-3371373869

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: update chart with dashboards validation [superset]

Posted by "dpgaspar (via GitHub)" <gi...@apache.org>.
dpgaspar merged PR #35523:
URL: https://github.com/apache/superset/pull/35523


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org