fix: compare single-branch oneOf schemas correctly - #111
Merged
l1shen merged 1 commit intoSep 7, 2026
Conversation
|
Warning Review limit reached
On-demand reviews are free for the next 13 days. After that, they cost $0.25 per reviewed file. Or wait 59 minutes for your next included review. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Comment |
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.
Summary
oneOfwith a single effective branch (for exampleoneOf: [{ type: 'string' }], or a two-branch list where one branch compiles tonever) compared as compatible against unrelated schemas.Changes
expression/calculator.ts:calculateOneOfreturns the single expression directly when only one branch remains, becauseoneOf([X])is equivalent toX.expression/calculator.ts:calculateCombinationnow throws on an empty expression list. The previouslength < 0guard could never trigger.test/designer/schema-compare.test.ts: regression cases for single-branchoneOfin both compatible and incompatible directions.Motivation
With one expression, the ban-zone computation evaluated
AnyOf([]), which returnedExpressionNone, and the defensiveExpressionContainedByfallback incalculateNodethen turned the empty result into a contained verdict. For example,compareJSONSchema({ oneOf: [{ type: 'string' }] }, { type: 'number' })reported compatible, so a string output could be connected to a number input in the designer.The compiler rejects empty
oneOflists and folds all-neverlists into theneverkind, so a combination reachingcalculateOneOfalways keeps at least one branch afterneverrejection; the empty-list guard is therefore unreachable hardening.Testing
bun run checkandbun run testinpackages/open-flow.oneOfto a matching type (compatible) and to a mismatched type (incompatible).