{"record":{"id":"165c0b214739cf35","repo":"apache/superset","slug":"a-chart-already-exists-and-user-doesn-t-have-permi","errorCode":null,"errorMessage":"A chart already exists and user doesn't have permissions to overwrite it","messagePattern":"A chart already exists and user doesn't have permissions to overwrite it","errorType":"exception","errorClass":"ImportFailedError","httpStatus":500,"severity":"error","filePath":"superset/commands/chart/importers/v1/utils.py","lineNumber":57,"sourceCode":"      annotation layers objects.\n    \"\"\"\n    params = chart_config.get(\"params\", {})\n    als = params.get(\"annotation_layers\", [])\n    params[\"annotation_layers\"] = [\n        al for al in als if al.get(\"annotationType\") == AnnotationType.FORMULA\n    ]\n\n\ndef _ensure_can_edit_existing_chart(\n    existing: Slice,\n    user: Any,\n    error_message: str,\n) -> None:\n    if user and (\n        not security_manager.can_access_chart(existing)\n        or not security_manager.is_editor(existing)\n    ):\n        raise ImportFailedError(error_message)\n\n\ndef _restore_existing_chart_for_import(\n    existing: Slice,\n    config: dict[str, Any],\n    can_write: bool,\n    user: Any,\n) -> None:\n    # RESTORE path — re-importing a soft-deleted UUID is an implicit\n    # restore-with-update, a distinct operation from overwriting an\n    # alive row, so it is handled in its own branch.\n    if not can_write:\n        # Case B: don't silently return a soft-deleted row to a caller\n        # without write permission — that would let the dashboard\n        # importer reattach to a deleted chart and produce a broken\n        # dashboard.\n        # Name the chart: a dashboard bundle imports many charts, and\n        # without the identity the operator can't tell which of N","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/chart/importers/v1/utils.py#L39-L75","documentation":"Raised as ImportFailedError by _ensure_can_edit_existing_chart during an overwrite import: a chart with the same UUID already exists, but the importing user either cannot access it (can_access_chart fails) or is not an editor/owner (is_editor fails). Overwrite mode reuses the existing row, so the caller must be allowed to modify that row.","triggerScenarios":"POST /api/v1/chart/import/ with overwrite=true where the UUID matches an existing chart owned by someone else and the user's role lacks chart edit rights; importing into a workspace whose RBAC restricts chart editing to owners.","commonSituations":"Team A importing a bundle that collides with Team B's chart of the same UUID; Gamma users importing shared exports without can_write.","solutions":["Import with overwrite=false so a new chart is created instead of modifying the existing one (requires create permission).","Have the existing chart's owner (or an Admin) run the import.","Add the importing user as an owner of the existing chart, then retry overwrite=true.","Change the bundle's UUID to avoid the collision."],"exampleFix":"# before\nclient.post('/api/v1/chart/import/', data={'overwrite': True}, ...)\n# -> ImportFailedError: A chart already exists and user doesn't have permissions to overwrite it\n\n# after: import as new chart instead of overwriting\nclient.post('/api/v1/chart/import/', data={'overwrite': False}, ...)","handlingStrategy":"validation","validationCode":"from superset import security_manager\nexisting = find_existing_for_import(Slice, config['uuid'])\nif existing and overwrite:\n    assert security_manager.can_access_chart(existing) and security_manager.is_editor(existing), \\\n        'cannot overwrite existing chart'","typeGuard":null,"tryCatchPattern":"from superset.commands.importers.exceptions import ImportFailedError\ntry:\n    import_chart(...)\nexcept ImportFailedError as ex:\n    if 'permissions to overwrite' in str(ex):\n        retry_with_overwrite_false_or_owner()","preventionTips":["Know UUID collisions in the target workspace before overwrite imports.","Run overwrite imports as the existing chart's owner or Admin.","Use overwrite=false when creating copies is acceptable."],"tags":["import-export","chart","permissions","overwrite","uuid"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}