apache/superset · error · ChartNotFoundError

Chart not found.

Error message

Chart not found.

What it means

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).

Source

Thrown at superset/commands/chart/unfave.py:49

logger = logging.getLogger(__name__)


class DelFavoriteChartCommand(BaseCommand):
    def __init__(self, chart_id: int) -> None:
        self._chart_id = chart_id
        self._chart: Slice | None = None

    @transaction(on_error=partial(on_error, reraise=ChartUnfaveError))
    def run(self) -> None:
        self.validate()
        if self._chart:
            return ChartDAO.remove_favorite(self._chart)

    def validate(self) -> None:
        chart = ChartDAO.find_by_id(self._chart_id)
        if not chart:
            raise ChartNotFoundError()
        try:
            security_manager.raise_for_access(chart=chart)
        except SupersetSecurityException as ex:
            raise ChartAccessDeniedError() from ex
        self._chart = chart

View on GitHub (pinned to f4587218dd)

Solutions

  1. Verify the chart id via GET /api/v1/chart/{id} before unfavoriting.
  2. Treat 404 as success — if the chart is gone, the favorite row is moot.
  3. Refresh favorites state in the client before issuing the call.

Example fix

# before
client.delete('/api/v1/chart/999/favorite/')  # 404 ChartNotFoundError

# after
if client.get('/api/v1/chart/999').status_code == 200:
    client.delete('/api/v1/chart/999/favorite/')
Defensive patterns

Strategy: validation

Validate before calling

if not ChartDAO.find_by_id(chart_id):
    raise ValueError(f'chart {chart_id} does not exist')

Try / catch

from superset.commands.chart.exceptions import ChartNotFoundError
try:
    UnfavoriteChartCommand(chart_id).run()
except ChartNotFoundError:
    pass  # chart gone; favorite is moot

Prevention

When it happens

Trigger: DELETE /api/v1/chart/{id}/favorite/ with a stale or nonexistent chart id; unfavorite raced with a chart deletion in another session.

Common situations: UI list out of sync after the chart was removed; automated scripts reusing ids across environments.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/de22a19b1dff3127. Report an issue: GitHub.