{"record":{"id":"0116875d3ded82d5","repo":"apache/superset","slug":"tag-with-name-tag-name-does-not-exist","errorCode":null,"errorMessage":"Tag with name {tag_name} does not exist.","messagePattern":"Tag with name (.+?) does not exist\\.","errorType":"exception","errorClass":"NoResultFound","httpStatus":null,"severity":"warning","filePath":"superset/daos/tag.py","lineNumber":81,"sourceCode":"            )\n\n            if not existing_tagged_object:\n                tagged_objects.append(\n                    TaggedObject(object_id=object_id, object_type=object_type, tag=tag)\n                )\n\n        db.session.add_all(tagged_objects)\n\n    @staticmethod\n    def delete_tagged_object(\n        object_type: ObjectType, object_id: int, tag_name: str\n    ) -> None:\n        \"\"\"\n        deletes a tagged object by the object_id, object_type, and tag_name\n        \"\"\"\n        tag = TagDAO.find_by_name(tag_name.strip())\n        if not tag:\n            raise NoResultFound(message=f\"Tag with name {tag_name} does not exist.\")\n\n        tagged_object = db.session.query(TaggedObject).filter(\n            TaggedObject.tag_id == tag.id,\n            TaggedObject.object_type == object_type,\n            TaggedObject.object_id == object_id,\n        )\n        if not tagged_object:\n            raise NoResultFound(\n                message=f'Tagged object with object_id: {object_id} \\\n                    object_type: {object_type} \\\n                    and tag name: \"{tag_name}\" could not be found'\n            )\n\n        db.session.delete(tagged_object.one())\n\n    @staticmethod\n    def delete_tags(tag_names: list[str]) -> None:\n        \"\"\"","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/daos/tag.py#L63-L99","documentation":"Raised by TagDAO.delete_tagged_object when no Tag row exists with the given name (after .strip()). It is a sqlalchemy-style NoResultFound wrapped Superset exception surfacing as 'Tag with name {tag_name} does not exist.' Delete-tagged-object first resolves the tag by name, then locates the TaggedObject join row; failure at the first step produces this error before any object lookup happens.","triggerScenarios":"DELETE on the tag-object API with a tag name that was already deleted or never existed; case-mismatched tag names ('Dashboard Of The Month' vs 'dashboard of the month'); leading/trailing whitespace already stripped by the DAO but internal spelling differences remaining.","commonSituations":"Race between two users removing the same tag; UI showing a stale tag list after another client deleted the tag; scripts replaying recorded tag names against a refreshed environment.","solutions":["Verify the tag exists first with TagDAO.find_by_name(tag_name.strip()) before deleting.","Refresh the tag list in the UI/script before issuing deletes to avoid stale names.","Treat this error as idempotent-success if the goal is 'make sure it is gone'.","Use the exact canonical spelling of the tag (names are case-sensitive)."],"exampleFix":"# before\nTagDAO.delete_tagged_object(object_type, object_id, 'Q3-KPIs')  # tag removed earlier -> NoResultFound\n\n# after\nfrom superset.daos.tag import TagDAO\nif TagDAO.find_by_name('Q3-KPIs'.strip()):\n    TagDAO.delete_tagged_object(object_type, object_id, 'Q3-KPIs')\n# else: nothing to do — already gone","handlingStrategy":"validation","validationCode":"from superset.daos.tag import TagDAO\n\ndef tag_exists(name: str) -> bool:\n    return TagDAO.find_by_name(name.strip()) is not None","typeGuard":null,"tryCatchPattern":"from superset.commands.tag.exceptions import TagNotFoundError\nfrom sqlalchemy.orm.exc import NoResultFound\ntry:\n    TagDAO.delete_tagged_object(object_type, object_id, tag_name)\nexcept NoResultFound:\n    pass  # tag already gone — treat as success","preventionTips":["Check tag existence by exact (case-sensitive) name before delete operations.","Refresh tag lists before destructive actions in UIs.","Design untag flows as idempotent no-ops on not-found."],"tags":["tags","dao","not-found","idempotency"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}