unslothai/unsloth · error · HTTPException

unsupported file type: {ext}

Error message

unsupported file type: {ext}

What it means

HTTP 422 raised in _read_preview_rows_from_local_file when the uploaded seed file's extension is not one of the handled types (.csv, .json, .jsonl handled above; .pdf/.docx/.txt/.md go through the unstructured path). Any other extension reaches the else branch and is rejected.

Source

Thrown at studio/backend/routes/data_recipe/seed.py:235

            df.columns = df.columns.str.strip()
            unnamed = [c for c in df.columns if c == "" or c.startswith("Unnamed:")]
            if unnamed:
                df = df.drop(columns = unnamed)
                full_df = pd.read_csv(path, encoding = "utf-8-sig")
                full_df.columns = full_df.columns.str.strip()
                full_df = full_df.drop(columns = unnamed)
                tmp_csv = path.with_suffix(".tmp.csv")
                full_df.to_csv(tmp_csv, index = False, encoding = "utf-8")
                tmp_csv.replace(path)
        elif ext == ".jsonl":
            df = pd.read_json(path, lines = True).head(preview_size)
        elif ext == ".json":
            try:
                df = pd.read_json(path).head(preview_size)
            except ValueError:
                df = pd.read_json(path, lines = True).head(preview_size)
        else:
            raise HTTPException(status_code = 422, detail = f"unsupported file type: {ext}")
    except HTTPException:
        raise
    except (ValueError, OSError) as exc:
        raise log_and_http_error(
            exc,
            422,
            "seed inspect failed",
            event = "data_recipe.seed.local_preview_failed",
            log = logger,
        ) from exc

    rows = df.to_dict(orient = "records")
    return _serialize_preview_rows(rows)


def _read_preview_rows_from_unstructured_file(
    *, path: Path, preview_size: int, chunk_size: int | None, chunk_overlap: int | None
) -> list[dict[str, Any]]:

View on GitHub (pinned to 203007d190)

Solutions

  1. Convert the file to CSV or JSONL before uploading (e.g. pandas df.to_csv).
  2. For documents (.pdf/.docx/.txt/.md), use the unstructured upload endpoint instead.
  3. Rename the file so it carries a supported extension matching its actual content.

Example fix

# before
pd.read_excel('data.xlsx').to_json('data.xlsx')  # still .xlsx, rejected

# after
pd.read_excel('data.xlsx').to_csv('data.csv', index=False)  # .csv accepted
Defensive patterns

Strategy: validation

Validate before calling

const STRUCTURED_EXTS = new Set(['.csv', '.json', '.jsonl']);
const ext = name.slice(name.lastIndexOf('.')).toLowerCase();
if (!STRUCTURED_EXTS.has(ext)) throw new Error(`convert ${name} to csv/json/jsonl first`);

Type guard

function isStructuredSeedFile(name: string): boolean {
  return ['.csv', '.json', '.jsonl'].includes(name.slice(name.lastIndexOf('.')).toLowerCase());
}

Try / catch

On 422 'unsupported file type', prompt the user to convert the file; do not silently retry with the same content.

Prevention

When it happens

Trigger: POST /seed/inspect-upload (or local-file inspect) with a file whose suffix is e.g. .xlsx, .tsv, .parquet, .zip, or empty because the original filename had no extension.

Common situations: User exports an Excel file and uploads it as a structured seed; file renamed losing its extension; uppercase extensions already lowercased by the code, so the real issue is a genuinely unsupported format.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/f4fb661134785ad4. Report an issue: GitHub.