{"record":{"id":"de22a19b1dff3127","repo":"apache/superset","slug":"chart-not-found-de22a1","errorCode":null,"errorMessage":"Chart not found.","messagePattern":"Chart not found\\.","errorType":"exception","errorClass":"ChartNotFoundError","httpStatus":500,"severity":"error","filePath":"superset/commands/chart/unfave.py","lineNumber":49,"sourceCode":"\nlogger = logging.getLogger(__name__)\n\n\nclass DelFavoriteChartCommand(BaseCommand):\n    def __init__(self, chart_id: int) -> None:\n        self._chart_id = chart_id\n        self._chart: Slice | None = None\n\n    @transaction(on_error=partial(on_error, reraise=ChartUnfaveError))\n    def run(self) -> None:\n        self.validate()\n        if self._chart:\n            return ChartDAO.remove_favorite(self._chart)\n\n    def validate(self) -> None:\n        chart = ChartDAO.find_by_id(self._chart_id)\n        if not chart:\n            raise ChartNotFoundError()\n        try:\n            security_manager.raise_for_access(chart=chart)\n        except SupersetSecurityException as ex:\n            raise ChartAccessDeniedError() from ex\n        self._chart = chart\n","sourceCodeStart":31,"sourceCodeEnd":55,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/chart/unfave.py#L31-L55","documentation":"Raised as ChartNotFoundError by UnfavoriteChartCommand.validate() when ChartDAO.find_by_id finds no chart for the given id. The unfavorite operation is aborted; the id does not exist in the charts table (deleted, mistyped, or from another environment).","triggerScenarios":"DELETE /api/v1/chart/{id}/favorite/ with a stale or nonexistent chart id; unfavorite raced with a chart deletion in another session.","commonSituations":"UI list out of sync after the chart was removed; automated scripts reusing ids across environments.","solutions":["Verify the chart id via GET /api/v1/chart/{id} before unfavoriting.","Treat 404 as success — if the chart is gone, the favorite row is moot.","Refresh favorites state in the client before issuing the call."],"exampleFix":"# before\nclient.delete('/api/v1/chart/999/favorite/')  # 404 ChartNotFoundError\n\n# after\nif client.get('/api/v1/chart/999').status_code == 200:\n    client.delete('/api/v1/chart/999/favorite/')","handlingStrategy":"validation","validationCode":"if not ChartDAO.find_by_id(chart_id):\n    raise ValueError(f'chart {chart_id} does not exist')","typeGuard":null,"tryCatchPattern":"from superset.commands.chart.exceptions import ChartNotFoundError\ntry:\n    UnfavoriteChartCommand(chart_id).run()\nexcept ChartNotFoundError:\n    pass  # chart gone; favorite is moot","preventionTips":["Treat unfavorite of a missing chart as a no-op.","Refresh favorites state before acting on it."],"tags":["chart","unfavorite","not-found","api"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}