Fix: Error when inserting an empty list in manyOf #43
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.
The bug is described in #42, but I would not consider this PR a fix as it does not address the error message helpfullness. Seems like more work need to be done there.
The problem this PR addresses is in the
ExpectManyOf
case ofMark.Internal.Description.matchExpected
. There are two variables there:oneOptions
twoOptions
In case of updates
oneOptions
will be a list of all valid options. ThetwoOptions
will be a list of blocks that are actually inserted.We want to check if all inserted blocks match any of the valid options. But it was the other way around - the test was "Are all valid options inserted?". Coincidentally when there is only one valid option and one block is inserted, the result is the same. That's probably why the problem remained undetected for relatively long time. I ran into it becasue my list was nested in a record (as described in the linked issue) and was initially empty.
That's also why I consider the error message unhelpful. It suggested there is something wrong with the record, but the "problem" was nested in one of the fields. I have some thoughts about improving this, but one thing at a time :D