ZodValidationError: fieldName is required after making field required in tRPC procedure
22K reputation · 02 Jun 2024, 07:11 UTC
Problem
The goal is to determine whether tRPC can safely roll back or tolerate a breaking schema change without causing client‑side validation failures. Currently, when a procedure’s Zod schema is altered—for example, by changing an optional field to required—the server validates incoming requests against the new schema and throws a ZodValidationError if the client still sends the old payload. There is no built‑in version‑negotiation or grace period that would allow the server to accept the deprecated shape for a limited time.
Constraints include the lack of automatic rollback mechanisms, the risk of UI degradation when clients are not updated simultaneously, and the reliance on client‑side error handling to detect mismatches. An open design question is whether tRPC should introduce optional schema versioning or a configurable tolerance window that permits deprecated fields before enforcing the new schema strictly.
What mechanisms could tRPC adopt to provide a safe rollback after a schema change? Should tRPC support a version header or similar signal to allow temporary backward compatibility? Is a grace‑period approach feasible without complicating the middleware pipeline?