{"record":{"id":"20fac8d8a2db2006","repo":"apache/superset","slug":"dataset-parameters-are-invalid","errorCode":null,"errorMessage":"Dataset parameters are invalid.","messagePattern":"Dataset parameters are invalid\\.","errorType":"validation","errorClass":"DatasetInvalidError","httpStatus":422,"severity":"error","filePath":"superset/commands/dataset/create.py","lineNumber":128,"sourceCode":"                        f\"Invalid SQL: {ex.error.message}\",\n                        field_name=\"sql\",\n                    )\n                )\n        elif database:\n            try:\n                security_manager.raise_for_access(\n                    database=database,\n                    table=table,\n                )\n            except SupersetSecurityException as ex:\n                exceptions.append(DatasetDataAccessIsNotAllowed(ex.error.message))\n\n        # Datasets have editors only — there is no ``sqlatable_viewers`` table,\n        # so a ``viewers`` key would be dropped by the DAO's ``setattr`` loop.\n        populate_subjects(self._properties, exceptions, include_viewers=False)\n\n        if exceptions:\n            raise DatasetInvalidError(exceptions=exceptions)\n","sourceCodeStart":110,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dataset/create.py#L110-L129","documentation":"DatasetInvalidError (HTTP 422, 'Dataset parameters are invalid.') is raised by the dataset create command when its validate() step accumulated one or more ValidationError entries; the errors list in the response carries the specifics. From this region: security_manager.raise_for_access(database=..., table=...) failing (DatasetDataAccessIsNotAllowed), and populate_subjects rejecting an invalid editors/owners list (viewers is explicitly rejected because dataset DAO drops it).","triggerScenarios":"POST /api/v1/dataset/ by a user lacking access to the target database/table; passing a `viewers` key (datasets have editors only, so it is a validation error); passing editors/owners entries that don't resolve to users/roles; combined with other checks earlier in validate() — duplicate table, table not found on the database.","commonSituations":"Gamma users creating datasets over databases they can only query through RLS or not at all; API payloads copied from dashboard imports that include viewers; usernames/role names that were renamed or deleted.","solutions":["Read the nested `errors` array in the 422 response — each entry names the offending field (e.g., 'sql' for access denied, 'editors', 'viewers').","Remove the `viewers` key from the payload; use `editors` (and `owners`) for datasets.","Grant the calling user access to the database/table (or have an admin create the dataset) when the error is DatasetDataAccessIsNotAllowed.","Verify every editors/owners entry resolves: usernames exist, roles exist, and ids are well-formed."],"exampleFix":"// before\n{\n  \"database\": 1,\n  \"table_name\": \"sales\",\n  \"viewers\": [{\"username\": \"alice\"}]  // rejected: datasets have no viewers\n}\n\n// after\n{\n  \"database\": 1,\n  \"table_name\": \"sales\",\n  \"editors\": [{\"username\": \"alice\"}]\n}","handlingStrategy":"validation","validationCode":"# Pre-validate a create payload the way the command does\nfrom superset import security_manager\nfrom superset.daos.dataset import DatasetDAO\n\ndef create_payload_valid(properties: dict) -> list[str]:\n    problems = []\n    if \"viewers\" in properties:\n        problems.append(\"datasets accept editors/owners only, not viewers\")\n    database = properties.get(\"database\")\n    table = properties.get(\"table_name\")\n    if database and table:\n        try:\n            security_manager.raise_for_access(\n                database=database, table=table\n            )\n        except Exception:\n            problems.append(\"no access to database/table\")\n    return problems  # empty == likely to pass","typeGuard":null,"tryCatchPattern":"from superset.commands.dataset.exceptions import DatasetInvalidError\ntry:\n    CreateDatasetCommand(properties).run()\nexcept DatasetInvalidError as ex:\n    # 422 with nested per-field errors: map each to its form field\n    for err in ex.normalized_errors():\n        mark_form_error(err.get(\"error_data\", {}).get(\"field_name\", \"base\"), err[\"message\"])","preventionTips":["Never send a `viewers` key for datasets — use `editors`/`owners`.","Verify the caller can access the target database/table before offering dataset creation over it.","Resolve editors/owners (existing usernames/roles) at payload-build time."],"tags":["dataset","validation","authorization","flask-api"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}