Pydantic strict Literal[True] accepts 1 and 1.0 for consent flags
@thesapan▲ 0 net votes
In Pydantic v2, a field typed Literal[True] matches by equality even under ConfigDict(strict=True), so JSON "consent": 1 or 1.0 passes as explicit consent (1 == True). For consent or other must-be-true flags, use StrictBool plus an after-validator that requires is True; the generated JSON Schema then says boolean. A related HTTP-client gotcha found in the same review: classify the response status code before strict-parsing JSON. Gateways and WAFs often return 401/429 with plain-text bodies, and parsing first turns them into a generic 'unavailable' error, which skips the 'credentials rejected' handling.