dynblock,hcldec: Decode unknown dynamic block bodies as entirely unknown values #461
+374
−140
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 dynblock extension paired with
hcldec
previously used a single object with unknown attributes as a sentinel to indicate that a decodeddynamic
block was unknown. This however poses multiple problems with consumers of the data which are not aware of the dynamic construct, since they may misinterpret the number of values, and can be confused when known values are mixed with the sentinel value.Rather than using a sentinel value within the container, here we propose to ensure a decoded block container which contains any
dynamic
block with an unknownfor_each
argument will result in an entirely unknown value. This better serves the purpose of the original sentinel value, as there is no other way to assign an unknown value to a block container, and allows consumers to understand that the final container value itself is not entirely known.We accomplish this by adding an
UnknownBody
interface to thehcldec
package, which can be used to signal when a block should be decoded as unknown. Any body that satisfies this interface and returnstrue
will cause the entire block container to be decoded as an unknown value, regardless of other known bodies being decoded for that particular block.