{"record":{"id":"b858d195b01ae75c","repo":"apache/superset","slug":"dataset-doesn-t-exist-and-user-doesn-t-have-permis","errorCode":null,"errorMessage":"Dataset doesn't exist and user doesn't have permission to create datasets","messagePattern":"Dataset doesn't exist and user doesn't have permission to create datasets","errorType":"exception","errorClass":"ImportFailedError","httpStatus":500,"severity":"error","filePath":"superset/commands/dataset/importers/v1/utils.py","lineNumber":379,"sourceCode":"            overwrite_identity = Table(\n                config.get(\"table_name\") or existing.table_name,\n                config.get(\"schema\", existing.schema),\n                config.get(\"catalog\", existing.catalog),\n            )\n            if not DatasetDAO.validate_update_uniqueness(\n                existing.database, overwrite_identity, dataset_id=existing.id\n            ):\n                raise ImportFailedError(\n                    f\"Dataset {existing.table_name!r} (uuid {config['uuid']}) \"\n                    \"cannot be overwritten: another dataset (possibly \"\n                    \"soft-deleted) already references the target table \"\n                    f\"({overwrite_identity.table!r}). Restore or rename the \"\n                    \"other dataset, or change this upload's table name.\"\n                )\n            config[\"id\"] = existing.id\n\n    elif not can_write:\n        raise ImportFailedError(\n            \"Dataset doesn't exist and user doesn't have permission to create datasets\"\n        )\n    else:\n        # Creating a brand-new dataset (no UUID match). A soft-deleted dataset\n        # may still claim this physical table; ``import_from_dict`` cannot see it\n        # (the visibility filter hides soft-deleted rows), so without this guard\n        # the import would create an active twin of a hidden dataset. The REST\n        # create path blocks the same collision via ``validate_uniqueness`` —\n        # mirror it here and direct the user to restore the existing dataset\n        # instead of leaving two rows for one physical table.\n        database = (\n            db.session.query(Database).filter_by(id=config[\"database_id\"]).first()\n        )\n        if database is not None and (\n            soft_twin := DatasetDAO.find_soft_deleted_logical_duplicate(\n                database,\n                Table(\n                    config[\"table_name\"], config.get(\"schema\"), config.get(\"catalog\")","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dataset/importers/v1/utils.py#L361-L397","documentation":"When the imported dataset's UUID matches nothing existing and the caller lacks can_write, import_dataset raises ImportFailedError('Dataset doesn't exist and user doesn't have permission to create datasets'). Creation via import requires the same write permission as the REST create path.","triggerScenarios":"Importing a bundle with brand-new dataset UUIDs under a role without the can_write dataset permission (ignore_permissions false, i.e. a normal user REST import).","commonSituations":"Viewer/Gamma-style roles attempting imports; import bundles for dashboards that include new datasets being loaded by analysts without create rights.","solutions":["Grant the role the can_write dataset permission (Dataset 'can_create'/write capability) and retry","Import only bundles whose datasets already exist (or drop the new dataset files)","Run the import as a user/role with dataset create rights"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"from superset import security_manager\n# pre-flight: does the caller have dataset write/create rights?\nif not security_manager.can_access('can_write', 'Dataset'):\n    raise PermissionError('new-dataset imports require dataset can_write')","typeGuard":null,"tryCatchPattern":"from superset.commands.exceptions import ImportFailedError\ntry:\n    import_dataset(config)\nexcept ImportFailedError as ex:\n    if \"doesn't have permission to create datasets\" in str(ex):\n        # run under a role with can_write, or strip new datasets from the bundle\n        ...","preventionTips":["Grant import-capable roles dataset write permission by design","Split bundles: existing datasets for readers, new datasets for creators","Use admin/importer service roles for automated imports"],"tags":["dataset-import","permissions","create","rbac","superset"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}