"I'm not convinced Zod is helping" One of my clients said this because the...


"I'm not convinced Zod is helping"

One of my clients said this because the app is occasionally throwing Zod errors when parsing API responses.

My reply? Zod isn't the problem. The problem is the API is returning bad data. Garbage in, garbage out.

Removing Zod is like removing types. The Zod errors will go away, but different errors will likely occur later instead.

Here are three real solutions to consider:
1. Resolve the data issues

2. "Widen" the Zod schemas to account for the data issues (for instance, allow for null/undefined even though the docs say we should always receive an array)

3. Configure Zod to quietly log errors instead of showing an error to the user. But doing so comes with risks: It means the app is then "limping" along with an untested data structure.

View original on X