{"record":{"id":"ffbd3d18f6476feb","repo":"apache/superset","slug":"chart-not-found-ffbd3d","errorCode":null,"errorMessage":"Chart not found.","messagePattern":"Chart not found\\.","errorType":"exception","errorClass":"ChartNotFoundError","httpStatus":500,"severity":"error","filePath":"superset/commands/chart/fave.py","lineNumber":49,"sourceCode":"\nlogger = logging.getLogger(__name__)\n\n\nclass AddFavoriteChartCommand(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=ChartFaveError))\n    def run(self) -> None:\n        self.validate()\n        if self._chart:\n            return ChartDAO.add_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/fave.py#L31-L55","documentation":"Raised as ChartNotFoundError by FavoriteChartCommand.validate() when ChartDAO.find_by_id returns nothing for the given chart id. Favoriting is aborted before any favorite row is written; the id simply does not exist in the charts table.","triggerScenarios":"POST /api/v1/chart/{id}/favorite/ with a nonexistent, already-deleted, or mistyped chart id; favoriting from a stale front-end list after the chart was removed elsewhere.","commonSituations":"Deep-linked favorites button on an expired chart id; scripts referencing ids from another environment.","solutions":["Confirm the chart exists via GET /api/v1/chart/{id} before favoriting.","Refresh the chart list in the UI and favorite from the current id.","Handle 404 as a no-op if the favorite is best-effort."],"exampleFix":"# before\nclient.post('/api/v1/chart/999/favorite/')  # 404 ChartNotFoundError\n\n# after\nresp = client.get('/api/v1/chart/999')\nif resp.status_code == 200:\n    client.post('/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    FavoriteChartCommand(chart_id).run()\nexcept ChartNotFoundError:\n    refresh_chart_list()  # stale id in UI","preventionTips":["Favorite only from freshly loaded chart lists.","Check chart existence before API calls in integrations."],"tags":["chart","favorite","not-found","api"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}