Don't throw a TypeError when trying to decode a sum value that contains a dangerous string #650
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.
I've recently started to see sporadic test failures for https://github.com/PREreview/prereview.org/blob/f1909e23b7d8a27d1d97e922dbdffa42a5b84570/test/write-review.test.ts#L1560-L1617. The test is probably hard to follow, but it's failing when using https://github.com/PREreview/prereview.org/blob/f1909e23b7d8a27d1d97e922dbdffa42a5b84570/src/write-review.ts#L59-L67 to decode a value generated by
fc.record({ competingInterests: fc.string() }, { withDeletedKeys: true })
The error is:
A failing value looks like this:
Fast-Check recently added a failure to generate strings containing JavaScript keywords and the like (dubzzz/fast-check#3043), revealing that io-ts crashes when trying to decode a sum type as the 'in' operator finds inherited properties such as 'toString'.
I looked at using Fast-Check in the test, but it needs to be upgraded and causes its other usages to fail, so I've just used a built-in property name instead.