Skip to content

File validation fails with MagicNumbersValidation #14977

@alumni

Description

@alumni

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I'm starting to get this error after updating from 10.4.15 to 10.4.17:

Validation failed (current file type is application/octet-stream, expected type is application/octet-stream)

Introduced in PR #14948 / #14881.

Minimum reproduction code

n/a

Steps to reproduce

async uploadFile(
  @UploadedFile(
    new ParseFilePipe({
      validators: [
        new FileTypeValidator({
          fileType: 'application/octet-stream',
          // skipMagicNumbersValidation: true,
        }),
      ],
    }),
  )
  file: Express.Multer.File,
  @Body() body: BodyDto,
) { ... }

Expected behavior

I would expect that 'application/octet-stream' === 'application/octet-stream' and the validation does not fail.

Workaround: set skipMagicNumbersValidation: true.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

10.4.17

Packages versions

[System Information]
OS Version     : macOS 24.3.0
NodeJS Version : v20.19.0
PNPM Version    : 9.15.9 

[Nest CLI]
Nest CLI Version : 10.4.9 

[Nest Platform Information]
platform-express version : 10.4.17
cache-manager version    : 2.3.0
bull-shared version      : 11.0.2
schematics version       : 10.2.3
schedule version         : 5.0.1
terminus version         : 11.0.0
swagger version          : 7.4.2
typeorm version          : 11.0.0
testing version          : 10.4.17
bullmq version           : 11.0.2
common version           : 10.4.17
config version           : 4.0.2
axios version            : 4.0.0
core version             : 10.4.17
mailer version           : 2.0.2

Node.js version

20.19.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been looked into

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions