apache/superset · error · TaggedObjectDeleteFailedError

invalid object type {object_type}

Error message

invalid object type {object_type}

What it means

DeleteTaggedObjectCommand.run() converts object_type with to_object_type(); if it maps to None it raises TaggedObjectDeleteFailedError(f'invalid object type {self._object_type}') (delete.py:51). As with creation, the same check runs in validate(), so hitting it in run() indicates an unrecognized type value reached execution.

Source

Thrown at superset/commands/tag/delete.py:51

from superset.tags.models import ObjectType
from superset.utils.decorators import on_error, transaction
from superset.views.base import DeleteMixin

logger = logging.getLogger(__name__)


class DeleteTaggedObjectCommand(DeleteMixin, BaseCommand):
    def __init__(self, object_type: ObjectType, object_id: int, tag: str):
        self._object_type = object_type
        self._object_id = object_id
        self._tag = tag

    @transaction(on_error=partial(on_error, reraise=TaggedObjectDeleteFailedError))
    def run(self) -> None:
        self.validate()
        object_type = to_object_type(self._object_type)
        if object_type is None:
            raise TaggedObjectDeleteFailedError(
                f"invalid object type {self._object_type}"
            )
        TagDAO.delete_tagged_object(object_type, self._object_id, self._tag)

    def validate(self) -> None:
        exceptions = []
        # Validate required arguments provided
        if not (self._object_id and self._object_type):
            exceptions.append(TaggedObjectDeleteFailedError())
        # Validate tagged object exists
        tag = TagDAO.find_by_name(self._tag)
        if not tag:
            exceptions.append(
                TaggedObjectDeleteFailedError(f"could not find tag: {self._tag}")
            )
        else:
            # Validate object type
            object_type = to_object_type(self._object_type)

View on GitHub (pinned to f4587218dd)

Solutions

  1. Use a supported object_type value (see the tag API schema for your version)
  2. Validate the type string before issuing the DELETE; log and skip unknown types in batch scripts
  3. Upgrade the lagging component so both sides share the same ObjectType vocabulary

Example fix

# before
DELETE /api/v1/tag/0/ tagged with {"object_type": "dash", "object_id": 1, "tag": "k"}
# after
{"object_type": "dashboard", "object_id": 1, "tag": "k"}
Defensive patterns

Strategy: type-guard

Validate before calling

def valid_object_type(t: str) -> bool:
    return to_object_type(t) is not None

Type guard

def is_known_object_type(value: str) -> bool:
    return to_object_type(value) is not None

Try / catch

try:
    DeleteTaggedObjectCommand(object_type, object_id, tag).run()
except TaggedObjectDeleteFailedError as ex:
    if 'invalid object type' in str(ex):
        correct_type_and_retry()

Prevention

When it happens

Trigger: DELETE of a tagged object (removing one tag from one object) with an object_type string outside the supported vocabulary — bad API payload, version skew, or scripted call with a typo.

Common situations: Automation deleting tags with hard-coded type names that drift across Superset versions; frontend/backend version mismatch introducing a new type the backend can't map.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/d9877ffb123cf42d. Report an issue: GitHub.