top of page

Why Does a Payload Fail When It Matches Both Allowed Schema Variants?

Oct 26
2 min read

A payload satisfies each of two proposed variants individually, yet the combined schema rejects it. The developer removes constraints until the request passes, unintentionally weakening the contract.


First check whether the combination requires exactly one matching variant. Matching both can be the reason for rejection.


State the intended logical rule


JSON Schema's combination reference defines oneOf as exactly one matching subschema and anyOf as one or more matching subschemas.


Those rules express different requirements. Select one based on the business meaning of the variants, not on which makes a troublesome fixture pass.


Describe whether a request may legitimately belong to multiple categories.


Build the overlap fixture


Illustrative example: two request shapes


A fictional API accepts a request with an email destination or a request with a queue destination. If each branch merely requires its own destination, a payload containing both can satisfy both branches.


Under oneOf, that overlap is invalid. Test the email-only case, queue-only case, both-destinations case and neither-destination case.


Write the expected result for all four before changing the schema.


Use an explicit variant when appropriate


If the workflow genuinely requires one mode, consider an explicit mode field with distinct allowed values and the matching branch requirements.


Check that each branch enforces the mode rather than merely documenting it. Keep irrelevant fields and contradictory combinations under an intentional policy.


This is a design choice to make the contract clearer, not a universal requirement for every schema.


Preserve the combination's purpose


Read cross-field validation rules when individual fields can be valid but their combination is not.


Replacing oneOf with anyOf changes which requests are accepted. Review downstream behavior for the newly accepted overlap before making that change.


If two destinations are allowed, define whether the application chooses one, uses both or rejects ambiguity later. Do not leave the operational meaning unspecified.


Make errors diagnosable


Capture which branches matched in a development fixture, while keeping production error responses appropriately concise.


A useful explanation distinguishes no matching variant from multiple matching variants. Both can fail oneOf, but they require different corrections.


Keep the schema dialect and validator version in the test record, especially when other advanced keywords are involved.


Accept the contract with boundary evidence


The final review should include one valid fixture per intended variant, overlap cases and missing-mode cases. Add a fixture for each contradictory combination the workflow must reject.


A schema is clearer when its accepted set of requests matches an explicit decision. The goal is not simply a green validation result; it is an unambiguous request that the receiving workflow knows how to process.


Editorial note


Prepared with AI assistance. Primary sources and the FutureOS article inventory were checked on October 26, 2026. Examples are illustrative, not customer results. FutureOS is described as being in prelaunch in its current introduction. This guide does not claim an available product feature, integration or service, and no independent expert review is claimed.


Comments


Commenting on this post isn't available anymore. Contact the site owner for more info.
bottom of page