Skip to content

[Bug] Zod v4 Compatibility Crash (TypeError) in Request Validation #3581

Description

@Sandeep6135

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

  1. 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).
  2. The schema validation will fail and throw a ZodError.
  3. 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,
             })),

Metadata

Metadata

Assignees

Labels

GSSoC'26Part of GirlScript Summer of Code 2026bugSomething isn't workingmentor:Ayushh-SharmaaGSSoC: Mentor — @Ayushh-Sharmaa

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions