Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(common): Add fallbackToMimetype support in FileTypeValidator#14995

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@mag123c
Copy link
Contributor

IntroducefallbackToMimetype option to allow fallback to mimetype validation when magic number detection fails (e.g., for small or undetectable buffers like text or CSV files).

Also enhancedbuildErrorMessage() to reflect precise validation failure reasons depending on buffer presence and mimetype state.

Added unit tests to cover fallback logic and error message variants.

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,FileTypeValidator only relies on magic number detection.
When the file buffer is too short or lacks a detectable signature, validation fails even if the mimetype is correctly set.

Issue Number:#14977

  • Allows developers to enable fallback to mimetype validation usingfallbackToMimetype: true
  • Better error messaging when fallback is triggered or buffer is missing
  • Adds relevant unit tests for fallback behavior and error formatting

What is the new behavior?

Does this PR introduce a breaking change?

Other information

Introduce `fallbackToMimetype` option to allow fallback to mimetype validationwhen magic number detection fails (e.g., for small or undetectable buffers like text or CSV files).Also enhanced `buildErrorMessage()` to reflect precise validation failure reasonsdepending on buffer presence and mimetype state.Added unit tests to cover fallback logic and error message variants.
@coveralls
Copy link

Pull Request Test Coverage Report forBuild 837e18fc-8678-46c2-8d75-8d045ee82c96

Details

  • 11 of12(91.67%) changed or added relevant lines in1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.003%) to89.318%

Changes Missing CoverageCovered LinesChanged/Added Lines%
packages/common/pipes/file/file-type.validator.ts111291.67%
TotalsCoverage Status
Change from baseBuild 600c1ebc-e7f1-48f2-bb00-a8366dddbcf8:-0.003%
Covered Lines:7166
Relevant Lines:8023

💛 -Coveralls

Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR introduces support for falling back to mimetype validation when magic number detection fails in FileTypeValidator, along with improved error messaging and additional unit tests.

  • Added fallbackToMimetype option to FileTypeValidator
  • Enhanced buildErrorMessage() to reflect fallback usage
  • Included new unit tests for fallback behavior and error message variants

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

FileDescription
packages/common/test/pipes/file/file-type.validator.spec.tsAdded tests for fallbackToMimetype logic and various error message scenarios
packages/common/pipes/file/file-type.validator.tsIntroduced fallbackToMimetype option in the validator and updated error messaging logic

@kamilmysliwiec
Copy link
Member

LGTM

mag123c reacted with thumbs up emoji

@kamilmysliwieckamilmysliwiec merged commit94bfde9 intonestjs:masterApr 22, 2025
5 checks passed
@mag123c
Copy link
ContributorAuthor

Just submitted a backport PR for 10.4.17:#15003
Happy to adjust if needed!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@mag123c@coveralls@kamilmysliwiec

[8]ページ先頭

©2009-2025 Movatter.jp