Fixing the error message for either in freeformType values

Summary of the issue, it would be best if everyone could fix their freeformTypes

We accidentally turned this into an abort unknowingly, We will change that now into a softer warning to make this non-breaking.

The issue is when types.either is used in freeformType, in the long term everyone who runs into this should fix the type.

  • types.either silently allowed any value. For example: types.either typeA typeB, provided with a value typeC would return the value C)

This is only a problem with freeformType, Because we also noticed that in contrast to normal module behavior it was never checked. This was like a ticking time bomb…

We removed the magical third case, and it seems a lot of people started relying on that bug in freeformType already.

freeformType = types.either null str → Didn’t throw any error even though it is impossible to set a matching value.

The proper type should have been:

freeformType = types.attrsOf (types.either null str)

freeformType should always be attrsOf ... because a module is always an attribute set.

Some other combinations such as nullOr either, number, oneOf (because they use either internally) might have the same issue when wrongly typed (in freeformType) i could have gone unnoticed.

If you want to go ahead a proper fix is to change freeformType, while we are currently deciding the best fix for this regression.

4 Likes

Can we please move the last two post to a different topic?

@hsjobeki as far as I can tell this case is not related to wrongly used freeForm types. It is rather a side effect. A settings (not even an option) was renamed an lead to that error. In this case a renaming warning would have been helpfull. My intention of posting this here is that other people could find a solution to the error above for this specific case.

1 Like