The validator that accepted everything
Level coordinators were seeing the whole school. Every symptom pointed at filtering: the queries looked wrong, the scope logic looked incomplete.
The filtering was fine. The level was never being saved.
Our staff form accepts one of several assignment shapes, expressed as a union of schemas. A union tries each branch in order and takes the first that parses. The academic branch came first — and every one of its fields is optional, which makes it a schema that matches literally anything.
So an administrative payload arrived, the academic branch said yes, this is me, and the administrative fields were discarded as extras. The form submitted successfully. No error appeared anywhere. The level silently ceased to exist between the browser and the database.
Two lessons, and the second is the one I’ll actually carry.
A schema of entirely optional fields is not a description of a shape — it’s a universal acceptor wearing the costume of one. Ordering a union so that the permissive branch comes first means the strict branches are unreachable.
And: validation that never rejects isn’t validation, it’s a filter you forgot you installed. It doesn’t fail loudly, it quietly deletes what it doesn’t recognise — which is the same failure mode as an object spread overwriting an earlier key, a bug we found in the same week, in the same codebase, wearing a different face.