You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first url, which has two elements, is correctly validated and we get a response.
Current behaviour
The second url, which has only one element, is not correctly validated and instead of having an array with one element we get the following validation error:
{"statusCode":400,"error":"Bad Request","message":"The request was not valid"}
with the following error log in the server:
js {"level":30,"time":1705507465376,"pid":50352,"hostname":"xxx","reqId":"req-1","res":{"statusCode":400},"err":{"type":"ValidationError","message":"The request was not valid","stack":"Validation Error: The request was not valid \n {\n \"name\": \"Validation Error\",\n \"errors\": [\n {\n \"path\": \"#/properties/chickenIds/type\",\n \"location\": \"querystring\",\n \"message\": \"must be array\",\n \"errorCode\": \"type\"\n }\n ],\n \"statusCode\": 400,\n \"message\": \"The request was not valid\"\n}","aggregateErrors":[{"type":"Object","message":"must be array","stack":"","path":"#/properties/chickenIds/type","location":"querystring","errorCode":"type"}],"name":"Validation Error","errors":[{"path":"#/properties/chickenIds/type","location":"querystring","message":"must be array","errorCode":"type"}],"statusCode":400},"msg":"The request was not valid"}
Expected behaviour
Even with one element we should treat this as an array of one element and not throw a validation error.
The text was updated successfully, but these errors were encountered:
Xavier-Redondo
changed the title
fastify: endpoint with query param as arry limitation
fastify: endpoint with query param as array limitation
Jan 17, 2024
Context
We define an endpoint that has a query param that is an array.
This is exemplified in this PR: #133
For this issues we are referring to the following endpoint defined in the api:
According to this endpoint, these url's should be valid:
http://localhost:8080/api/array-query-param?chickenIds=2&chickenIds=3
http://localhost:8080/api/array-query-param?chickenIds=2
The first url, which has two elements, is correctly validated and we get a response.
Current behaviour
The second url, which has only one element, is not correctly validated and instead of having an array with one element we get the following validation error:
{"statusCode":400,"error":"Bad Request","message":"The request was not valid"}
with the following error log in the server:
js {"level":30,"time":1705507465376,"pid":50352,"hostname":"xxx","reqId":"req-1","res":{"statusCode":400},"err":{"type":"ValidationError","message":"The request was not valid","stack":"Validation Error: The request was not valid \n {\n \"name\": \"Validation Error\",\n \"errors\": [\n {\n \"path\": \"#/properties/chickenIds/type\",\n \"location\": \"querystring\",\n \"message\": \"must be array\",\n \"errorCode\": \"type\"\n }\n ],\n \"statusCode\": 400,\n \"message\": \"The request was not valid\"\n}","aggregateErrors":[{"type":"Object","message":"must be array","stack":"","path":"#/properties/chickenIds/type","location":"querystring","errorCode":"type"}],"name":"Validation Error","errors":[{"path":"#/properties/chickenIds/type","location":"querystring","message":"must be array","errorCode":"type"}],"statusCode":400},"msg":"The request was not valid"}
Expected behaviour
Even with one element we should treat this as an array of one element and not throw a validation error.
The text was updated successfully, but these errors were encountered: