fix(analysis): requiredness branches may restate type: object - #91
Merged
lightsofapollo merged 2 commits intoOct 2, 2026
Merged
Conversation
A union whose branches only list required properties constrains the object; it isn't a variant of it. A branch that also says `type: object` was read as an empty object variant, though only an object has required properties, so it says nothing the requiredness doesn't. An `allOf` of two such unions then failed as intersecting multiple union members, and one beside a real union competed with it for the variant. The corpus doesn't change: no pinned spec has such a branch. Fixes gpu-cli#88
|
@iamralch is attempting to deploy a commit to the lbl-rd Team on Vercel. A member of the Team first needs to authorize it. |
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #88.
What was wrong
A union whose branches only list required properties constrains the object; it isn't a variant of it.
union_only_constrains_requirednessalready treats it that way, but only when each branch has nothing butrequired,not, nested unions and annotations. A branch that also saystype: objectwas read as an empty object variant:With two of them in an
allOf, generation failed:and one beside a real union competed with it for the variant.
The change
schema_only_constrains_requirednessalso acceptstype: "object"in a branch, and nothing else fortype. Only an object has required properties, so it says nothing the requiredness doesn't.Tests
In
tests/recoverable_typing_test.rs, beside the existing requiredness case:requiredness_branches_that_restate_type_object_are_still_only_requiredness: the schema above, Cloudflare's Email Sending builder, is a struct of its properties.a_requiredness_union_beside_a_real_union_leaves_that_union_the_variant: Cloudflare's Magic WAN app config, aoneOfof account or managed app beside ananyOfofrequired: [breakout]orrequired: [priority], keeps theoneOfas its variant.Both fail before this change.
cargo test --all-features: 720 passed, none failed.The corpus doesn't move:
scripts/gen-diff.sh upstream/mainreports every spec identical, since no pinned spec has such a branch. The pinnedcloudflarespec predates both of these schemas. Against the current cloudflare/api-schemas, both now generate, without the overlay we used to work around them.#88 lists a third Cloudflare case, the Workers Observability
filters: anallOfof a$refto a union and an inline copy of the same union. That isn't requiredness, and this doesn't change it.This and #90 both add a
Fixedentry under[Unreleased]inCHANGELOG.md, so whichever merges second needs that resolved. I'll rebase.