{"record":{"id":"af1038cdb45469e8","repo":"apache/superset","slug":"chart-not-found-af1038","errorCode":null,"errorMessage":"Chart not found.","messagePattern":"Chart not found\\.","errorType":"exception","errorClass":"ChartNotFoundError","httpStatus":null,"severity":"error","filePath":"superset/daos/chart.py","lineNumber":126,"sourceCode":"        if remaining_operators:\n            query = super().apply_column_operators(query, remaining_operators)\n        return query\n\n    @classmethod\n    def get_filterable_columns_and_operators(cls) -> Dict[str, List[str]]:\n        filterable = super().get_filterable_columns_and_operators()\n        # Add custom fields for charts\n        filterable.update(CHART_CUSTOM_FIELDS)\n        return filterable\n\n    @staticmethod\n    def get_by_id_or_uuid(id_or_uuid: str) -> Slice:\n        query = db.session.query(Slice).filter(id_or_uuid_filter(id_or_uuid))\n        # Apply chart base filters\n        query = ChartFilter(\"id\", SQLAInterface(Slice, db.session)).apply(query, None)\n        chart = query.one_or_none()\n        if not chart:\n            raise ChartNotFoundError()\n        return chart\n\n    @staticmethod\n    def favorited_ids(charts: list[Slice]) -> list[FavStar]:\n        ids = [chart.id for chart in charts]\n        return [\n            star.obj_id\n            for star in db.session.query(FavStar.obj_id)\n            .filter(\n                FavStar.class_name == FavStarClassName.CHART,\n                FavStar.obj_id.in_(ids),\n                FavStar.user_id == get_user_id(),\n            )\n            .all()\n        ]\n\n    @staticmethod\n    def add_favorite(chart: Slice) -> None:","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/daos/chart.py#L108-L144","documentation":"ChartNotFoundError raised by ChartDAO.get_by_id_or_unicode(): the query by id-or-uuid (id_or_uuid_filter) additionally passes through ChartFilter (the DAO base/access filter), so 'not found' also covers 'exists but you can't see it'. one_or_none() returning None — either no row matches the id/uuid or the access filter removed it — triggers the error.","triggerScenarios":"GET /api/v1/chart/<id-or-uuid> for a chart that was deleted, for an id/uuid that never existed, or for a chart the current user lacks permission to see (ChartFilter strips it). Malformed UUID in the id_or_uuid string also yields no match.","commonSituations":"Stale chart id/uuid in a bookmark, dashboard JSON, or API integration after the chart was deleted; a Gamma user requesting an admin-owned chart; copy/paste truncating the UUID.","solutions":["Verify the chart exists and is visible to the acting user: list with GET /api/v1/chart/?q=(filter on id) as the same user.","Use the chart's UUID (from the dashboard export or chart URL) rather than an integer id if ids may differ across environments.","If permission is the cause, grant the user/role access (owner, roles, or all-users access on the chart).","Remove the stale reference from the calling artifact."],"exampleFix":"# before\nchart = ChartDAO.get_by_id_or_uuid(\"abc123\")  # stale id from an old export\n\n# after\nimport requests\nresp = requests.get(\"/api/v1/chart/\", params={\"q\": '{\"filter\": [{\"col\": \"uuid\", \"opr\": \"eq\", \"value\": \"<uuid>\"}]}'})\n# resolve the live uuid first, then fetch it","handlingStrategy":"try-catch","validationCode":"def chart_exists_and_visible(id_or_uuid: str) -> bool:\n    try:\n        ChartDAO.get_by_id_or_uuid(id_or_uuid)\n        return True\n    except ChartNotFoundError:\n        return False","typeGuard":"def looks_like_uuid(s: str) -> bool:\n    import uuid\n    try:\n        uuid.UUID(s)\n        return True\n    except (ValueError, AttributeError, TypeError):\n        return False","tryCatchPattern":"try:\n    chart = ChartDAO.get_by_id_or_uuid(id_or_uuid)\nexcept ChartNotFoundError:\n    abort(404)  # covers both deleted and not-visible","preventionTips":["Reference charts by UUID in persistent integrations; ids are environment-specific.","Verify visibility by listing as the acting user before deep-linking.","Distinguish 404 (gone/invisible) from 403 in API handlers."],"tags":["dao","chart","not-found","permissions","api"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}