villebro commented on code in PR #43390:
URL: https://github.com/apache/superset/pull/43390#discussion_r3836147854


##########
superset/commands/tag/delete.py:
##########
@@ -134,10 +137,42 @@ def run(self) -> None:
         TagDAO.delete_tags(self._tags)
 
     def validate(self) -> None:
-        exceptions = []
-        # Validate tag exists
-        for tag in self._tags:
-            if not TagDAO.find_by_name(tag):
-                exceptions.append(TagNotFoundError(tag))
+        # Every item appended here must be a ValidationError (or subclass),
+        # since TagInvalidError.normalized_messages() calls
+        # .normalized_messages() on each one to build the aggregated 422
+        # response.
+        exceptions: list[ValidationError] = []
+        for tag_name in self._tags:
+            tag_name = tag_name.strip()
+            tag = TagDAO.find_by_name(tag_name)
+            # Validate tag exists
+            if not tag:
+                exceptions.append(
+                    TagNotFoundValidationError(f"Tag with name {tag_name} not 
found.")
+                )
+                continue
+            # System-generated tags (type:*, editor:*, favorited_by:*) are
+            # maintained by Superset itself and must not be deletable through
+            # the bulk route.
+            if tag.type is not None and tag.type != TagType.custom:
+                exceptions.append(
+                    TagDeleteForbiddenValidationError(
+                        f"Tag {tag_name} is a system tag and cannot be deleted"
+                    )
+                )
+                continue

Review Comment:
   Btw, while I was working on the Subject feature, I noticed these system 
generated tags are apparently not used anywhere(!). So while we're at it, I 
suggest we consider removing them all together if they're not used at all.



-- 
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