{"record":{"id":"86d7d687437f944b","repo":"apache/superset","slug":"parsing-error-error-s-86d7d6","errorCode":null,"errorMessage":"Parsing error: %(error)s","messagePattern":"Parsing error: (.+?)","errorType":"exception","errorClass":"DatabaseUploadFailed","httpStatus":422,"severity":"error","filePath":"superset/commands/database/uploaders/csv_reader.py","lineNumber":450,"sourceCode":"                        index_col = kwargs.get(\"index_col\")\n                        if isinstance(index_col, str):\n                            result.index.name = index_col\n                    df = result\n            else:\n                df = pd.read_csv(\n                    filepath_or_buffer=file.stream,\n                    **kwargs,\n                )\n\n            if types:\n                df = CSVReader._cast_column_types(df, types, kwargs)\n\n            return df\n        except DatabaseUploadFailed:\n            raise\n        except UnicodeDecodeError as ex:\n            if encoding != DEFAULT_ENCODING:\n                raise DatabaseUploadFailed(\n                    message=_(\"Parsing error: %(error)s\", error=str(ex))\n                ) from ex\n\n            file.seek(0)\n            detected_encoding = CSVReader._detect_encoding(file)\n            if detected_encoding != encoding:\n                kwargs[\"encoding\"] = detected_encoding\n                return CSVReader._read_csv(file, kwargs)\n            raise DatabaseUploadFailed(\n                message=_(\"Parsing error: %(error)s\", error=str(ex))\n            ) from ex\n        except (\n            pd.errors.ParserError,\n            pd.errors.EmptyDataError,\n            ValueError,\n        ) as ex:\n            raise DatabaseUploadFailed(\n                message=_(\"Parsing error: %(error)s\", error=str(ex))","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/database/uploaders/csv_reader.py#L432-L468","documentation":"DatabaseUploadFailed ('Parsing error: <UnicodeDecodeError detail>') raised in CSVReader._read_csv when pd.read_csv hits undecodable bytes AND the request explicitly set a non-default encoding (encoding != UTF-8 default). Because the user pinned the encoding, Superset does not attempt detection and surfaces the raw decode error, e.g. \"'utf-8' codec can't decode byte 0xff in position 12\".","triggerScenarios":"Selecting an encoding in the upload UI (e.g. utf-8, latin-1) that does not match the file's actual byte content: choosing utf-8 for a UTF-16/cp1252 file, or a single-byte encoding for a file containing multi-byte characters.","commonSituations":"Excel 'CSV UTF-8' vs plain 'CSV' exports (UTF-8 with BOM vs cp1252); files re-saved by editors in another encoding; explicit encoding chosen from a dropdown while the file was converted in between.","solutions":["Set encoding to match the file: run 'file -bi data.csv' (gives charset=...) and select that encoding","If unsure, omit the explicit encoding and let Superset's detection path retry (only available when encoding equals the default)","Re-save/export the CSV as UTF-8 from the source application"],"exampleFix":"file -bi data.csv\n# charset=iso-8859-1 -> choose ISO-8859-1 in the upload dialog\n# or in the source app: Save As -> 'CSV UTF-8'","handlingStrategy":"validation","validationCode":"def file_matches_encoding(path: str, encoding: str) -> bool:\n    try:\n        open(path, encoding=encoding).read(4096)\n        return True\n    except UnicodeDecodeError:\n        return False","typeGuard":null,"tryCatchPattern":"except DatabaseUploadFailed as ex:\n    if 'codec' in str(ex):\n        # wrong encoding selected: detect and retry with the reported charset\n        ...","preventionTips":["Detect charset first: file -bi data.csv","Export from source apps as UTF-8","Only pin an encoding when certain of the file's charset"],"tags":["csv","encoding","unicode","file-upload"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}