Skip to content

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?

The FileTypeValidator dynamically imports the file-type package using loadEsm. This approach can lead to loading the wrong version of file-type if another package (like jimp) installs a different version that gets hoisted, resulting in inconsistent or incorrect file validation results.

This was reported in #15270, where developers were encountering issues like:
Validation failed (current file type is application/octet-stream, expected type is ...)

Issue Number: 15270

What is the new behavior?

  • Replaced dynamic import using loadEsm with a direct static import:
    import { fileTypeFromBuffer } from 'file-type';

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This fix ensures more predictable and stable validation behavior in file uploads by removing reliance on hoisted or mismatched file-type versions. It improves compatibility and aligns the package with modern best practices for peer dependency handling.

@Yasir-Rafique Yasir-Rafique force-pushed the fix/file-type-peer-dependency branch from 5311d3d to ab38864 Compare July 2, 2025 06:14
@coveralls
Copy link

coveralls commented Jul 2, 2025

Pull Request Test Coverage Report for Build 65d65112-245d-4e15-88dc-e384fa504be2

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 88.918%

Totals Coverage Status
Change from base Build bc91b2b9-9bd0-4dac-a3ac-a0d262be1578: 0.0%
Covered Lines: 7197
Relevant Lines: 8094

💛 - Coveralls

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