{"record":{"id":"2749b48c66272c53","repo":"apache/superset","slug":"chart-not-found-2749b4","errorCode":null,"errorMessage":"Chart not found.","messagePattern":"Chart not found\\.","errorType":"exception","errorClass":"ChartNotFoundError","httpStatus":500,"severity":"error","filePath":"superset/commands/chart/update.py","lineNumber":176,"sourceCode":"            exceptions.append(ChartQueryContextDatasourceMismatchValidationError())\n\n    def validate(self) -> None:  # noqa: C901\n        exceptions: list[ValidationError] = []\n        dashboard_ids = self._properties.get(\"dashboards\")\n        tag_ids: Optional[list[int]] = self._properties.get(\"tags\")\n\n        # Validate if datasource_id is provided datasource_type is required\n        datasource_id = self._properties.get(\"datasource_id\")\n        datasource_type = \"\"\n        if datasource_id is not None:\n            datasource_type = self._properties.get(\"datasource_type\", \"\")\n            if not datasource_type:\n                exceptions.append(DatasourceTypeUpdateRequiredValidationError())\n\n        # Validate/populate model exists\n        self._model = ChartDAO.find_by_id(self._model_id)\n        if not self._model:\n            raise ChartNotFoundError()\n\n        # Check and update editorship; when only updating query context we relax\n        # editorship so report workers can save context. We still require chart\n        # access so users cannot rewrite query context for charts they cannot access.\n        if not is_query_context_update(self._properties):\n            try:\n                security_manager.raise_for_editorship(self._model)\n                compute_subjects(self._model, self._properties, exceptions)\n            except SupersetSecurityException as ex:\n                raise ChartForbiddenError() from ex\n            except ValidationError as ex:\n                exceptions.append(ex)\n        else:\n            try:\n                security_manager.raise_for_access(chart=self._model)\n            except SupersetSecurityException as ex:\n                raise ChartForbiddenError() from ex\n            # Keep the refreshed payload bound to the chart's own datasource so it","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/chart/update.py#L158-L194","documentation":"Raised as ChartNotFoundError in UpdateChartCommand.validate() when ChartDAO.find_by_id(self._model_id) returns None: the chart id being updated does not exist. The update aborts before any property validation runs.","triggerScenarios":"PUT /api/v1/chart/{id} with a deleted or never-existing id; updating from a stale Explore session after the chart was removed; id confusion across environments.","commonSituations":"Long-lived Explore tabs referencing a chart deleted elsewhere; CI scripts reusing recorded ids against a reset database.","solutions":["Confirm existence with GET /api/v1/chart/{id} and correct the id.","If the chart was deleted intentionally, create a new chart instead of updating.","Reload Explore from the chart list to pick up the current id."],"exampleFix":"# before\nclient.put('/api/v1/chart/999', json={'slice_name': 'renamed'})  # 404 ChartNotFoundError\n\n# after\nchart = client.get('/api/v1/chart/999')\nif chart.status_code == 200:\n    client.put('/api/v1/chart/999', json={'slice_name': 'renamed'})","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    UpdateChartCommand(chart_id, props).run()\nexcept ChartNotFoundError:\n    reload_and_recreate_or_retarget()","preventionTips":["Re-fetch chart ids before updates in long-lived sessions.","Handle 404 in chart-edit scripts by refreshing state."],"tags":["chart","update","not-found","api"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}