{"record":{"id":"996b713bfcaa75f9","repo":"apache/superset","slug":"invalid-object-type-object-type","errorCode":null,"errorMessage":"invalid object type {object_type}","messagePattern":"invalid object type (.+?)","errorType":"exception","errorClass":"TagCreateFailedError","httpStatus":500,"severity":"error","filePath":"superset/commands/tag/create.py","lineNumber":48,"sourceCode":"from superset.exceptions import SupersetSecurityException\nfrom superset.tags.models import ObjectType, TagType\nfrom superset.utils.decorators import on_error, transaction\n\nlogger = logging.getLogger(__name__)\n\n\nclass CreateCustomTagCommand(CreateMixin, BaseCommand):\n    def __init__(self, object_type: ObjectType, object_id: int, tags: list[str]):\n        self._object_type = object_type\n        self._object_id = object_id\n        self._tags = tags\n\n    @transaction(on_error=partial(on_error, reraise=TagCreateFailedError))\n    def run(self) -> None:\n        self.validate()\n        object_type = to_object_type(self._object_type)\n        if object_type is None:\n            raise TagCreateFailedError(f\"invalid object type {self._object_type}\")\n\n        TagDAO.create_custom_tagged_objects(\n            object_type=object_type,\n            object_id=self._object_id,\n            tag_names=self._tags,\n        )\n\n    def validate(self) -> None:\n        exceptions = []\n        # Validate object_id\n        if self._object_id == 0:\n            exceptions.append(TagCreateFailedError())\n        # Validate object type\n        object_type = to_object_type(self._object_type)\n        if not object_type:\n            exceptions.append(\n                TagCreateFailedError(f\"invalid object type {self._object_type}\")\n            )","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/tag/create.py#L30-L66","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\ncurl -X POST /api/v1/tag/ -d '{\"object_type\": \"dashboardz\", \"object_id\": 1, \"tags\": [\"k\"]}'\n# after\ncurl -X POST /api/v1/tag/ -d '{\"object_type\": \"dashboard\", \"object_id\": 1, \"tags\": [\"k\"]}'","handlingStrategy":"type-guard","validationCode":"SUPPORTED_OBJECT_TYPES = {'dashboard', 'chart', 'query', 'dataset'}  # match your version's API schema\n\ndef valid_object_type(t: str) -> bool:\n    return t in SUPPORTED_OBJECT_TYPES","typeGuard":"def is_known_object_type(value: str) -> bool:\n    return to_object_type(value) is not None","tryCatchPattern":"try:\n    CreateCustomTagCommand(object_type, object_id, tags).run()\nexcept TagCreateFailedError as ex:\n    if 'invalid object type' in str(ex):\n        fix_type_and_resubmit(ex)","preventionTips":["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"],"tags":["tags","api","validation"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}