{"record":{"id":"8691c9d064f5575d","repo":"apache/superset","slug":"annotation-not-found-8691c9","errorCode":null,"errorMessage":"Annotation not found.","messagePattern":"Annotation not found\\.","errorType":"exception","errorClass":"AnnotationNotFoundError","httpStatus":404,"severity":"error","filePath":"superset/commands/annotation_layer/annotation/update.py","lineNumber":61,"sourceCode":"        self._model_id = model_id\n        self._properties = data.copy()\n        self._model: Optional[Annotation] = None\n\n    @transaction(on_error=partial(on_error, reraise=AnnotationUpdateFailedError))\n    def run(self) -> Model:\n        self.validate()\n        assert self._model\n        return AnnotationDAO.update(self._model, self._properties)\n\n    def validate(self) -> None:\n        exceptions: list[ValidationError] = []\n        layer_id: Optional[int] = self._properties.get(\"layer\")\n        short_descr: str = self._properties.get(\"short_descr\", \"\")\n\n        # Validate/populate model exists\n        self._model = AnnotationDAO.find_by_id(self._model_id)\n        if not self._model:\n            raise AnnotationNotFoundError()\n        # Validate/populate layer exists\n        if layer_id:\n            annotation_layer = AnnotationLayerDAO.find_by_id(layer_id)\n            if not annotation_layer:\n                raise AnnotationLayerNotFoundError()\n            self._properties[\"layer\"] = annotation_layer\n\n            # Validate short descr uniqueness on this layer\n            if not AnnotationDAO.validate_update_uniqueness(\n                layer_id,\n                short_descr,\n                annotation_id=self._model_id,\n            ):\n                exceptions.append(AnnotationUniquenessValidationError())\n        else:\n            self._properties[\"layer\"] = self._model.layer\n\n        # validate date time sanity","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/annotation_layer/annotation/update.py#L43-L79","documentation":"AnnotationNotFoundError from UpdateAnnotationCommand.validate() (update.py:61): AnnotationDAO.find_by_id(self._model_id) returned None, so the annotation being PATCHed no longer exists. HTTP 404. The command is instantiated with a model id from the URL, so this means the target itself is gone, not a related object.","triggerScenarios":"PATCH /api/v1/annotation/<id> after that annotation was deleted in another tab/session; editing from a stale list view; replaying an update request against a different metadata DB.","commonSituations":"Two users editing the same annotation layer simultaneously; long-open editor pages whose row was removed; environment mismatch in scripted updates.","solutions":["GET /api/v1/annotation/<id> first; if 404, remove the row from the client list instead of patching.","Refresh the annotation list after concurrent deletes and reapply the edit to a live row.","In scripts, guard updates with an existence check and treat 404 as a no-op."],"exampleFix":"# before\nUpdateAnnotationCommand(model_id=42, properties).run()\n\n# after\nfrom superset.daos.annotation_layer import AnnotationDAO\nif AnnotationDAO.find_by_id(42) is None:\n    log.info(\"annotation 42 gone; skipping update\")\nelse:\n    UpdateAnnotationCommand(model_id=42, properties).run()","handlingStrategy":"validation","validationCode":"from superset.daos.annotation_layer import AnnotationDAO\n\nif AnnotationDAO.find_by_id(annotation_id) is None:\n    remove_from_client_list(annotation_id); return  # skip update","typeGuard":null,"tryCatchPattern":"try:\n    UpdateAnnotationCommand(model_id, properties).run()\nexcept AnnotationNotFoundError:\n    refresh_annotation_list(); notify_user(\"annotation was deleted by another session\")","preventionTips":["Verify the annotation still exists (GET) before showing an edit form save action.","Refresh lists after concurrent-editing sessions; lock or notify on concurrent deletes.","In scripts, make PATCH guarded by existence checks and idempotent."],"tags":["annotation","not-found","update","stale-state"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}