apache/superset · error · TagCreateFailedError
invalid object type {object_type}
Error message
invalid object type {object_type} What it means
CreateCustomTagCommand.run() converts the requested object_type via to_object_type(); if the value does not map to a known ObjectType enum, it raises TagCreateFailedError(f'invalid object type {self._object_type}') (create.py:48). Note the same condition is also caught earlier in validate(), so reaching run() means an unmapped-but-truthy type value slipped through.
Source
Thrown at superset/commands/tag/create.py:48
from superset.exceptions import SupersetSecurityException
from superset.tags.models import ObjectType, TagType
from superset.utils.decorators import on_error, transaction
logger = logging.getLogger(__name__)
class CreateCustomTagCommand(CreateMixin, BaseCommand):
def __init__(self, object_type: ObjectType, object_id: int, tags: list[str]):
self._object_type = object_type
self._object_id = object_id
self._tags = tags
@transaction(on_error=partial(on_error, reraise=TagCreateFailedError))
def run(self) -> None:
self.validate()
object_type = to_object_type(self._object_type)
if object_type is None:
raise TagCreateFailedError(f"invalid object type {self._object_type}")
TagDAO.create_custom_tagged_objects(
object_type=object_type,
object_id=self._object_id,
tag_names=self._tags,
)
def validate(self) -> None:
exceptions = []
# Validate object_id
if self._object_id == 0:
exceptions.append(TagCreateFailedError())
# Validate object type
object_type = to_object_type(self._object_type)
if not object_type:
exceptions.append(
TagCreateFailedError(f"invalid object type {self._object_type}")
)View on GitHub (pinned to f4587218dd)
Solutions
- Send one of the supported object types (consult the API schema / ObjectType mapping used by the tag endpoints — dashboard, chart, query, dataset as supported by your version)
- Align frontend and backend versions so the object_type vocabulary matches
- If calling the API directly, validate object_type against the OpenAPI spec at /swagger/v1 before sending
Example fix
# before
curl -X POST /api/v1/tag/ -d '{"object_type": "dashboardz", "object_id": 1, "tags": ["k"]}'
# after
curl -X POST /api/v1/tag/ -d '{"object_type": "dashboard", "object_id": 1, "tags": ["k"]}' Defensive patterns
Strategy: type-guard
Validate before calling
SUPPORTED_OBJECT_TYPES = {'dashboard', 'chart', 'query', 'dataset'} # match your version's API schema
def valid_object_type(t: str) -> bool:
return t in SUPPORTED_OBJECT_TYPES Type guard
def is_known_object_type(value: str) -> bool:
return to_object_type(value) is not None Try / catch
try:
CreateCustomTagCommand(object_type, object_id, tags).run()
except TagCreateFailedError as ex:
if 'invalid object type' in str(ex):
fix_type_and_resubmit(ex) Prevention
- Derive object_type from the API's enum/schema, never hardcode
- Keep frontend and backend versions aligned
- Lint API payloads against /swagger/v1 in CI for custom integrations
When it happens
Trigger: POST /api/v1/tag/ with an object_type the server does not recognize — e.g. a newly added frontend type not present in this backend version, or a hand-crafted API call with a bad string.
Common situations: Version skew between superset-frontend and backend (frontend sends a type the backend's to_object_type doesn't map); direct API consumers guessing the object_type vocabulary; typo'd automation scripts.
Related errors
- Tag parameters are invalid.
- invalid object type {object_type}
- Tag parameters are invalid.
- Dashboard %(dashboard_id)s not found
- Annotation layer not found.
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/996b713bfcaa75f9.
Report an issue: GitHub.