mikebridge commented on code in PR #44416:
URL: https://github.com/apache/superset/pull/44416#discussion_r4048177547


##########
superset/commands/chart/update.py:
##########
@@ -203,22 +208,20 @@ def validate(self) -> None:  # noqa: C901
         # we don't clobber that message with DatasourceTypeInvalidError.
         if datasource_type:
             try:
-                # Slice.datasource only ever resolves the ``table``
-                # relationship (see Slice.datasource in
-                # superset/models/slice.py), so setting datasource_type to
-                # anything else would "succeed" but leave the chart
-                # permanently unable to render -- even for a type-only
-                # update that leaves datasource_id untouched. Reject those
-                # up front instead of failing later -- either at the lookup
-                # below (SavedQuery/Query have no ``.name`` attribute, so
-                # accessing it raises an unhandled AttributeError) or
-                # silently.
-                if datasource_type != DatasourceType.TABLE:
-                    raise DatasourceTypeInvalidError()
-                if datasource_id is not None:
-                    datasource = get_datasource_by_id(datasource_id, 
datasource_type)
-                    self._properties["datasource_name"] = datasource.name
-                    security_manager.raise_for_access(datasource=datasource)
+                validate_chart_datasource_type(datasource_type)
+                # A type-only change still selects a different datasource 
namespace.
+                effective_id: int | None = (
+                    datasource_id
+                    if datasource_id is not None
+                    else self._model.datasource_id
+                )

Review Comment:
   Good catch — fixed in 
https://github.com/apache/superset/commit/5d3bf53ad23cb70bfb19f697c1663a4734e7a04a.
 The stored ID is used only when datasource_id is absent; explicit null reaches 
DatasourceNotFoundValidationError and the 422 mapping before any lookup/access 
check. Both TABLE and semantic-view null cases failed before the change and 
pass afterward; 101 command/Explore tests and 110 chart API tests pass.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to