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
Run the application and invoke the endpoint with curl -X POST 'http://localhost:3000'
Describe the bug
readValidatedBody(event, validate) throw an error with message "Cannot read properties of undefined (reading 'message')" if the validate returns false.
(Expected message here might be "Validation Failed")
Internal function createValidationError() accepts undefined as parameter, uses it without checking if it is undefined.
Environment
h3: 1.9.0
Node.js: v20.5.1
Reproduction
Call the
readValidatedBody()
function with validate that returns false.details:
Initialize a nitro project(v2.8.1) and add a route file with following contents:
Run the application and invoke the endpoint with
curl -X POST 'http://localhost:3000'
Describe the bug
readValidatedBody(event, validate)
throw an error with message"Cannot read properties of undefined (reading 'message')"
if thevalidate
returnsfalse
.(Expected message here might be
"Validation Failed"
)Internal function
createValidationError()
accepts undefined as parameter, uses it without checking if it is undefined.h3/src/utils/internal/validate.ts
Lines 38 to 41 in afc4183
validateData
actually callscreateValidationError()
with no parameter when ValidateFunction returnsfalse
.h3/src/utils/internal/validate.ts
Lines 20 to 28 in afc4183
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: