← Back to Pull requests

fix: always detect CSV files as text/csv on Windows #13485

Open
unknown opened this pull request with 400 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 30, 2026 00:49 UTC
Author

Related Issues

  • none filed; found by running the unit suite on Windows (test_from_file_path_guess_mime_type[spam.csv-...] fails there)
  • Proposed Changes:

    _guess_mime_type asks the mimetypes module first and only falls back to CUSTOM_MIMETYPES for extensions it does not know. On Windows, mimetypes reads the registry, where Excel registers .csv as application/vnd.ms-excel. So on any Windows machine with Excel installed, CSV files are no longer text/csv:

    >>> FileTypeRouter(mime_types=["text/csv"]).run(sources=[Path("data.csv")])
    {'unclassified': [WindowsPath('data.csv')]}
    >>> MultiFileConverter().run(sources=[Path("data.csv")])
    {'unclassified': 1}
    

    MultiFileConverter routes CSV by text/csv, so CSV files are silently skipped instead of reaching CSVToDocument. This adds .csv to CUSTOM_MIMETYPES (the dict that already pins .md and .msg, and takes precedence over the system guess), so the result no longer depends on the registry. Behaviour on Linux and macOS is unchanged, they already return text/csv.

    How did you test it?

  • New unit test patches mimetypes.guess_type to return application/vnd.ms-excel and checks _guess_mime_type still returns text/csv (also for upper-case .CSV); it fails without the change.

  • On Windows 11 (registry value for .csv is application/vnd.ms-excel): FileTypeRouter(["text/csv"]) goes from unclassified to text/csv for a real CSV file; the previously failing test_byte_stream.py::test_from_file_path_guess_mime_type[spam.csv-...] passes.

  • test/utils, test/dataclasses/test_byte_stream.py, test/components/routers, test/components/converters/test_multi_file_converter.py: 265 passed, 39 skipped. Rest of the non-integration unit suite on Windows: 7087 passed, 1 failed (the csv test above).

  • pre-commit run on the three changed files: all hooks pass (ruff check, ruff format, codespell, release-note-backticks, yaml and whitespace checks; actionlint skipped because no workflow file changed).
  • Notes for the reviewer

    Release note added. If you would rather not pin the type in CUSTOM_MIMETYPES, the alternative is to skip the system guess for .csv inside _guess_mime_type; I kept the existing mechanism.

    Checklist

  • I have read the contributors guidelines and the code of conduct.

  • I have updated the related issue with new insights and changes.

  • I have added unit tests and updated the docstrings.

  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.

  • I have documented my code.

  • I have added a release note file, following the contributors guidelines.

  • I have run pre-commit hooks and fixed any issue.
  • Diff: 400 lines (+300 / -100) across 5 files Reviewer: simin-yuan Review duration: 36826m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.45) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 400 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #13485"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.7% (MEDIUM) · Higher = larger blast radius
    44.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.5% · Safe to merge
    25.5%