{"record":{"id":"29ae73739006eec1","repo":"apache/superset","slug":"no-data-in-file","errorCode":null,"errorMessage":"No data in file","messagePattern":"No data in file","errorType":"exception","errorClass":"DashboardImportException","httpStatus":500,"severity":"warning","filePath":"superset/commands/dashboard/importers/v0.py","lineNumber":308,"sourceCode":"    if \"__SqlMetric__\" in o:\n        return SqlMetric(**o[\"__SqlMetric__\"])\n    if \"__datetime__\" in o:\n        return datetime.strptime(o[\"__datetime__\"], \"%Y-%m-%dT%H:%M:%S\")\n\n    return o\n\n\ndef import_dashboards(\n    content: str,\n    database_id: Optional[int] = None,\n    import_time: Optional[int] = None,\n) -> None:\n    \"\"\"Imports dashboards from a stream to databases\"\"\"\n    current_tt = int(time.time())\n    import_time = current_tt if import_time is None else import_time\n    data = json.loads(content, object_hook=decode_dashboards)\n    if not data:\n        raise DashboardImportException(_(\"No data in file\"))\n    dataset_id_mapping: dict[int, int] = {}\n    # This legacy path creates/updates the embedded datasets. Mirror the\n    # versioned (v1) import commands and require dataset write permission for the\n    # objects being created here. Only enforced when there is something to import\n    # and a request user is present, so the CLI import paths keep working.\n    if (\n        data[\"datasources\"]\n        and get_user()\n        and not security_manager.can_access(\"can_write\", \"Dataset\")\n    ):\n        raise ImportFailedError(\n            \"User doesn't have permission to create or update datasets\"\n        )\n    for table in data[\"datasources\"]:\n        new_dataset_id = import_dataset(table, database_id, import_time=import_time)\n        params = json.loads(table.params)\n        dataset_id_mapping[params[\"remote_id\"]] = new_dataset_id\n","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dashboard/importers/v0.py#L290-L326","documentation":"DashboardImportException('No data in file') is raised by the legacy v0 import_dashboards() when json.loads of the uploaded content produces an empty result. The v0 path expects a JSON payload (old-format export with 'datasources' and 'dashboards' keys); an empty object, empty array, or effectively empty JSON body triggers this before any processing.","triggerScenarios":"Uploading an empty JSON file or a file whose JSON root is falsy ({}, []) to the legacy dashboard import; feeding an old-format export that was truncated or reduced to an empty structure.","commonSituations":"Automation piping an empty or failed export into import; manual construction of v0 JSON files that ends up as {}; upstream fetch step silently failing and writing an empty file that is then imported.","solutions":["Inspect the file being imported: it must contain non-empty 'datasources' and 'dashboards' arrays in old v0 JSON format.","Fix the upstream export step that produced an empty file (check its logs/status) before importing.","Prefer the modern ZIP/YAML v1 export+import flow instead of the legacy JSON path."],"exampleFix":"# before\nimport_dashboards(open('dashboards.json').read())  # file contains '{}'\n\n# after\nimport json\ndata = json.loads(content)\nif not data or not data.get('dashboards'):\n    raise ValueError('Export file is empty; regenerate it from the source instance')\nimport_dashboards(content)","handlingStrategy":"validation","validationCode":"import json\n\ndata = json.loads(content)\nif not data or not data.get('dashboards'):\n    raise ValueError('legacy export file is empty; regenerate from source')","typeGuard":null,"tryCatchPattern":"try:\n    import_dashboards(content)\nexcept DashboardImportException as ex:\n    if 'No data in file' in str(ex):\n        regenerate_export_file()","preventionTips":["Check export step exit status before piping its output into import.","Prefer the v1 ZIP format over legacy JSON imports.","Validate non-empty 'dashboards'/'datasources' arrays before calling the importer."],"tags":["import","dashboard","legacy","v0","empty-file"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}