{"record":{"id":"67a2bbd5818f4fcf","repo":"apache/superset","slug":"database-upload-file-failed","errorCode":null,"errorMessage":"Database upload file failed","messagePattern":"Database upload file failed","errorType":"exception","errorClass":"DatabaseUploadFailed","httpStatus":422,"severity":"error","filePath":"superset/commands/database/uploaders/base.py","lineNumber":140,"sourceCode":"            ):\n                to_sql_kwargs[\"index_label\"] = self._options.get(\"index_label\")\n            database.db_engine_spec.df_to_sql(\n                database,\n                data_table,\n                df,\n                to_sql_kwargs=to_sql_kwargs,\n            )\n        except ValueError as ex:\n            raise DatabaseUploadFailed(\n                message=_(\n                    \"Table already exists. You can change your \"\n                    \"'if table already exists' strategy to append or \"\n                    \"replace or provide a different Table Name to use.\"\n                )\n            ) from ex\n        except Exception as ex:\n            message = ex.message if hasattr(ex, \"message\") and ex.message else str(ex)\n            raise DatabaseUploadFailed(message=message, exception=ex) from ex\n\n\nclass UploadCommand(BaseCommand):\n    def __init__(  # pylint: disable=too-many-arguments\n        self,\n        model_id: int,\n        table_name: str,\n        file: Any,\n        schema: Optional[str],\n        reader: BaseDataReader,\n    ) -> None:\n        self._model_id = model_id\n        self._model: Optional[Database] = None\n        self._table_name = table_name\n        self._schema = schema\n        self._file = file\n        self._reader = reader\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/database/uploaders/base.py#L122-L158","documentation":"DatabaseUploadFailed is the generic wrapper for any exception during the dataframe-to-SQL write in BaseUploader; the message is taken from ex.message when present, otherwise str(ex). It is the catch-all failure mode for file uploads beyond the specific guard clauses.","triggerScenarios":"Any non-ValueError exception from df_to_sql: dtype inference failures, constraint violations, driver errors, oversized payloads, permission errors on the target schema.","commonSituations":"CSVs with mixed/inferable-bad dtypes, target-table schema mismatches, DB write privilege missing, network drops mid-upload.","solutions":["Read the propagated message and the chained exception (exception=ex) in logs","Fix data-level issues (dtypes, nulls, encoding) or target-table constraints it names","If it is actually the exists-conflict, switch the if-exists strategy (see the 'Table already exists' variant)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    UploadCommand(...).run()\nexcept DatabaseUploadFailed as e:\n    original = e.exception  # chained cause\n    logger.error(\"upload failed: %s\", original)\n    # branch on original type (dtype, permissions, network)\n    ...","preventionTips":["Validate/clean CSV dtypes and encoding before upload","Keep the chained exception for diagnosis instead of swallowing it"],"tags":["database","upload","unexpected"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}