Description
The request validation wrapper crashes with a TypeError when handling validation failures because it attempts to access the deprecated/removed errors property of ZodError under Zod v4 (project uses "zod": "^4.4.3").
Code Location
- File:
lib/validations/validateRequest.js
// Line 23
details: error.errors.map((issue) => ({
path: issue.path.join("."),
message: issue.message,
})),
Steps to Reproduce
- Send an HTTP request to any validated endpoint (e.g.,
POST /api/attendance/record) with an invalid payload parameter type (e.g., sending a non-numeric string for confidenceScore).
- The schema validation will fail and throw a
ZodError.
- The server will respond with a
500 Internal Server Error instead of a validation warning due to the unhandled TypeError.
Impact
Standard validation error mapping fails, turning client input errors (which should return a clean 422 Unprocessable Entity or 400 Bad Request code with details) into unhandled 500 Internal Server Error crashes.
Recommended Fix
Update the validation wrapper to query issues instead of errors to restore compatibility with Zod v4:
- details: error.errors.map((issue) => ({
+ details: (error.issues || error.errors || []).map((issue) => ({
path: issue.path.join("."),
message: issue.message,
})),
Description
The request validation wrapper crashes with a
TypeErrorwhen handling validation failures because it attempts to access the deprecated/removederrorsproperty of ZodError under Zod v4 (project uses"zod": "^4.4.3").Code Location
lib/validations/validateRequest.jsSteps to Reproduce
POST /api/attendance/record) with an invalid payload parameter type (e.g., sending a non-numeric string forconfidenceScore).ZodError.500 Internal Server Errorinstead of a validation warning due to the unhandledTypeError.Impact
Standard validation error mapping fails, turning client input errors (which should return a clean
422 Unprocessable Entityor400 Bad Requestcode with details) into unhandled500 Internal Server Errorcrashes.Recommended Fix
Update the validation wrapper to query
issuesinstead oferrorsto restore compatibility with Zod v4: