chore(common): Backport FileTypeValidator fallback support to v10.4.17#15003
chore(common): Backport FileTypeValidator fallback support to v10.4.17#15003mag123c wants to merge 1 commit into
Conversation
|
Hi @UseInterceptors( The file is saved in the upload folder, so the buffer is missing in the file that is transmitted to validation. |
|
@mehdirayan The issue for verifying the magic-number, the root cause of the issue, has not yet been resolved. |
themavik
left a comment
There was a problem hiding this comment.
fallbackToMimetype means when fileTypeFromBuffer returns null you accept the client mimetype regex, which is weaker than magic-byte checks—call that out for security-minded users. The short-buffer vs mismatch specs help.
|
Hi, When magic-number detection throws, isValid() returns false without attempting mimetype fallback even if fallbackToMimetype is enabled. This breaks the intended “fallback when detection fails” behavior for import/parsing/runtime errors. Severity: action required | Category: correctness How to fix: Apply fallback in catch block Agent prompt to fix - you can give this to your LLM of choice:
Qodo code review - free for open-source. |
|
Hi, buildErrorMessage() appends “magic number detection failed, used mimetype fallback” whenever fallbackToMimetype is enabled, even if validation failed due to a detected magic-number mismatch (where fallback was not used). This produces factually incorrect error messages. Severity: remediation recommended | Category: observability How to fix: Only mention fallback when used Agent prompt to fix - you can give this to your LLM of choice:
Found by Qodo code review |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
File validation fails when the buffer is too small or unidentifiable by magic number,
even if the mimetype is correct.
Related issue: #14977
What is the new behavior?
fallbackToMimetypeoption toFileTypeValidatorbuildErrorMessage()for clearer failure messagesDoes this PR introduce a breaking change?
Other information
This PR backports the fix originally merged in #14995 into the
10.4.17line.This was originally reported in #14977. All tests have been verified on the v10 codebase.