-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kernel): correct deserialization of structs in union contexts (#919)
When deserializing structures in a Union context, the Kernel used to try options in an arbitrary order (actually - the declaration order which often is alphanumerically sorted). In addition, it would ignore any additional property encountered silently. In cases where several of the union's possibilities had overlapping required properties, the first attempted option would succeed, even if a subsequent option would have consumed more properties. A pathologic case of this is when the first candidate is a type with only optional properties; as such a type would *always* successfully deserialize anything, possibly ignoring all properties. In order to address this, the `structs` can now be passed into the Kernel by wrapping the object in a decorator box: ```js { "$jsii.struct": { "fqn": "fully.qualified.struct.TypeName", "data": { /* the actual data included in the struct instance */ } } } ``` This enables "native" languages to correctly communicate the intended type to the Kernel, so it can make an appropriate deserialization decision. The encoding of structs from the Kernel to "native" languages has not changed: those are still passed by-reference in order to maximize the compatibility; and to avoid undeterministic behavior in case where union of structs are returned. Fixes #822 Fixes aws/aws-cdk#3917 Fixes aws/aws-cdk#2013
- Loading branch information
1 parent
c7d2fc1
commit c0f338e
Showing
82 changed files
with
2,026 additions
and
256 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.