{"record":{"id":"137134e35c48aaa7","repo":"apache/superset","slug":"chart-doesn-t-exist-and-user-doesn-t-have-permissi","errorCode":null,"errorMessage":"Chart doesn't exist and user doesn't have permission to create charts","messagePattern":"Chart doesn't exist and user doesn't have permission to create charts","errorType":"exception","errorClass":"ImportFailedError","httpStatus":500,"severity":"error","filePath":"superset/commands/chart/importers/v1/utils.py","lineNumber":190,"sourceCode":"    can_write = ignore_permissions or security_manager.can_access(\"can_write\", \"Chart\")\n    # `user` is None for background / example-loader paths (no Flask request\n    # user). Combined with ``can_write=True`` (typically from\n    # ``ignore_permissions=True``), the editorship checks in the restore /\n    # overwrite branches below are intentionally skipped because the caller has\n    # already established trust at the command level.\n    user = get_user()\n\n    if existing := find_existing_for_import(Slice, config[\"uuid\"]):\n        if existing_chart := _prepare_existing_chart_for_import(\n            existing,\n            config,\n            overwrite,\n            can_write,\n            user,\n        ):\n            return existing_chart\n    elif not can_write:\n        raise ImportFailedError(\n            \"Chart doesn't exist and user doesn't have permission to create charts\"\n        )\n\n    filter_chart_annotations(config)\n\n    # TODO (betodealmeida): move this logic to import_from_dict\n    config[\"params\"] = json.dumps(config[\"params\"])\n\n    # migrate old viz types to new ones\n    config = migrate_chart(config)\n\n    chart = Slice.import_from_dict(config, recursive=False, allow_reparenting=True)\n    if chart.id is None:\n        db.session.flush()\n\n    # Only newly created charts inherit the creator's editor/viewer defaults;\n    # re-importing over an existing chart (overwrite or soft-delete restore)\n    # must not silently grant the importer's groups access. Mirrors the","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/chart/importers/v1/utils.py#L172-L208","documentation":"Raised as ImportFailedError when the bundle contains no existing chart with that UUID (find_existing_for_import returns None) and the caller lacks can_write, which in the import flow doubles as the permission to create new charts. Without can_write the import cannot proceed on either the overwrite or create branch.","triggerScenarios":"POST /api/v1/chart/import/ into a workspace where the chart UUID is absent, performed by a user whose role has no chart create/write capability; also when overwrite=false and no implicit create rights exist.","commonSituations":"Gamma-level users importing shared chart bundles; service accounts missing the can_write chart permission; fresh environments where the bundle was never imported before.","solutions":["Grant the importing user/role chart write (create) permission and retry.","Run the import as Admin.","Pre-create the chart (or a first import by an admin) so subsequent imports hit the overwrite path instead of create."],"exampleFix":"# before\nclient.post('/api/v1/chart/import/', files=...)  # ImportFailedError: ...no permission to create charts\n\n# after: import with a role that has can_write on charts, e.g. Admin\nadmin_client.post('/api/v1/chart/import/', files=...)","handlingStrategy":"validation","validationCode":"if find_existing_for_import(Slice, config['uuid']) is None and not can_write:\n    raise PermissionError('importing new charts requires can_write')","typeGuard":null,"tryCatchPattern":"from superset.commands.importers.exceptions import ImportFailedError\ntry:\n    import_chart(...)\nexcept ImportFailedError as ex:\n    if 'permission to create' in str(ex):\n        run_import_as_admin()","preventionTips":["Use an Admin or can_write role for first-time imports of a bundle.","Pre-seed charts via an admin import so later imports hit the overwrite path."],"tags":["import-export","chart","permissions","create","uuid"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}