Skip to content

fix(collections): Normalize file extension case - #1193

Merged
AkhileshNegi merged 3 commits into
mainfrom
fix/kb-uppercase-extension
Sep 9, 2026
Merged

AkhileshNegi merged 3 commits into
mainfrom
fix/kb-uppercase-extension

Conversation

@AkhileshNegi

@AkhileshNegi AkhileshNegi commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Closes #1196

Summary

A knowledge base document uploaded as report.PDF is accepted at upload — get_file_format lowercases the suffix — and fname is stored with its original case, since it drives the download attachment name. upload_files then handed that name to files.create verbatim, so an uppercase suffix reached the provider.

OpenAI file search may not match an uppercase suffix in every ingestion path, and a failed file in a batch is a hard failure that rolls back the whole vector store — so one such document can take an entire collection job down rather than failing alone.

  • Now: files.create receives the stem plus a lowercased extension. The stored fname is untouched, so download attachment names keep their original case.
  • Documented the invariant in docs/wiki/modules/knowledge-base.md under Gotchas.

Notes

  • The provider-side mechanism is stated as a possibility, not a confirmed rejection — normalizing the case is a cheap invariant either way, and the blast radius if it does fail is the whole collection job.
  • Extension rejection and surfacing messages through collection_job.error_message were described in an earlier revision of this description but are not part of this diff. This PR is the case-normalization fix only.
  • The two filename tests were collapsed into one parametrized case covering report.pdf → report.pdf, Report.PDF → Report.pdf, and the extensionless README → README, which had no coverage before.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ready-for-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 255a5103-e6f0-4838-8066-8af59c4bbc56

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AkhileshNegi AkhileshNegi changed the title fix(collections): normalize file extension case for OpenAI fix(collections): normalize file extension case for OpenAI uploads Sep 8, 2026
@github-actions github-actions Bot changed the title fix(collections): normalize file extension case for OpenAI uploads fix(collections): Normalize file extension case Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

OpenAPI changes   ⚪ No API surface changes

Note

This PR does not modify the API contract.

main ↔ 217c2060 · generated by oasdiff

@AkhileshNegi
AkhileshNegi marked this pull request as ready for review September 8, 2026 17:25
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

A knowledge base document uploaded as `report.PDF` is accepted at upload —
`get_file_format` lowercases the suffix — and `fname` is stored with its
original case, since it drives the download attachment name. OpenAI file
search may not match an uppercase suffix in every ingestion path, and a
failed file in a batch is a hard failure that rolls back the whole vector
store.

Send `files.create` the stem plus a lowercased extension; the stored
`fname` is untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@AkhileshNegi
AkhileshNegi force-pushed the fix/kb-uppercase-extension branch from 0641588 to 8d462dd Compare September 9, 2026 03:44
Use string rsplit instead of pathlib import. Same pattern already in codebase
(stt_evaluations/audio.py). Clear variable names: filename + extension.
@AkhileshNegi
AkhileshNegi force-pushed the fix/kb-uppercase-extension branch from c8c84ba to 5baeeee Compare September 9, 2026 07:52
The two upload_files filename tests differed only in input/expected, so
collapse them and add the extensionless case, which had no coverage.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@AkhileshNegi AkhileshNegi self-assigned this Sep 9, 2026
@AkhileshNegi AkhileshNegi added the bug Something isn't working label Sep 9, 2026
@Ayush8923 Ayush8923 added reviewed and removed bug Something isn't working labels Sep 9, 2026
@AkhileshNegi
AkhileshNegi merged commit 506d8b6 into main Sep 9, 2026
9 of 10 checks passed
@AkhileshNegi
AkhileshNegi deleted the fix/kb-uppercase-extension branch September 9, 2026 10:00
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.6.1-main.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@Ayush8923 Ayush8923 linked an issue Sep 14, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File Upload: Lowercase file extensions Knowledge Base: Normalize file extensions

2 participants