We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
7.7.3
8.0.0
18
macOS
13.6
When setting {attachFieldsToBody: 'keyValues'}, the content of the file is attached to the body, using the name of the field.
{attachFieldsToBody: 'keyValues'}
According to the documentation here: https://github.com/fastify/fastify-multipart#json-schema-body-validation, we'd expect a string.
However, since version 8.0.0 (specifically, this particular change here: c195d5f#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346L176, the object is attached as a Buffer.
Using JSON Schema, as far as I know, it is not possible to represent a Buffer object.
Here is a short example of a server:
import fastifyMultipart from "@fastify/multipart"; import fastify from "fastify"; const app = fastify({ ignoreTrailingSlash: true }); app.register(fastifyMultipart, { attachFieldsToBody: "keyValues", }); app.post( "/test", { schema: { body: { type: "object", properties: { myFile: { type: "string" }, }, }, }, }, async (request, reply) => { reply.send(); } ); app.listen({ port: 3000 });
It works fine in 7.7.3. With 8.0.0, myFile is now a Buffer, and this server returns this:
myFile
{ "statusCode": 400, "error": "Bad Request", "message": "body/myFile must be string" }
body.myFile
The text was updated successfully, but these errors were encountered:
Good spot, the docs shouldn’t say that
Sorry, something went wrong.
You can use the object type for buffers
object
Successfully merging a pull request may close this issue.
Prerequisites
Last working version
7.7.3
Stopped working in version
8.0.0
Node.js version
18
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.6
💥 Regression Report
When setting
{attachFieldsToBody: 'keyValues'}
, the content of the file is attached to the body, using the name of the field.According to the documentation here: https://github.com/fastify/fastify-multipart#json-schema-body-validation, we'd expect a string.
However, since version 8.0.0 (specifically, this particular change here: c195d5f#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346L176, the object is attached as a Buffer.
Using JSON Schema, as far as I know, it is not possible to represent a Buffer object.
Steps to Reproduce
Here is a short example of a server:
It works fine in 7.7.3. With 8.0.0,
myFile
is now a Buffer, and this server returns this:Expected Behavior
body.myFile
should be a string, or there is a documented clear way of defining a Buffer in the JSON Schema validationThe text was updated successfully, but these errors were encountered: