Skip to content

fix(testing): add fallback option to file type validator #15226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Yasir-Rafique
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently, the FileTypeValidator fails when file-type is unable to determine the MIME type — particularly for file formats with undetectable signatures. This can cause valid uploads to fail unexpectedly.

Additionally, the related unit test did not cover scenarios involving fallback logic or validator option validation.

Issue Number: #15055

What is the new behavior?

  • Added mimeTypeFallback support to the FileTypeValidator to allow more resilient handling when file-type cannot detect MIME.
  • Improved the test case in parse-file-pipe.builder.spec.ts to assert that validator options (including mimeTypeFallback) are properly passed and used.
  • Updated package.json:
  • Downgraded redis from v5 (ESM-only) to ^4.7.1 for compatibility.
  • Moved redis from devDependencies to dependencies.
  • Ensured backwards compatibility with existing file validation logic.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This PR resolves compatibility issues related to MIME type detection and improves developer experience by making file validation more fault-tolerant in real-world uploads. It also keeps dependencies aligned with current CommonJS-based usage patterns.

@coveralls
Copy link

coveralls commented Jun 4, 2025

Pull Request Test Coverage Report for Build aa574eec-13f3-4118-a75c-4fbdd7e27af8

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 88.919%

Totals Coverage Status
Change from base Build 6bb0bd44-444d-4735-bfc6-38320412dad8: 0.001%
Covered Lines: 7198
Relevant Lines: 8095

💛 - Coveralls

@Yasir-Rafique
Copy link
Author

All conflicts have been resolved, and checks are passing. Ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants