Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issues-391] Fix document typecheck in encoding for nested types #394

Merged
merged 3 commits into from Oct 21, 2022

Conversation

isaiahvita
Copy link
Contributor

This resolves github issue 391 where encoding of document types is not checking to see if nested types are explicitly marked for no serialization or deserialization. In order to to check for every layer of nesting, I moved the noserde check to the recursive layer from the original top-level function. This mimics how it correctly works in decoding

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This resolves github issue 391 where encoding of document types
is not checking to see if nested types are explicitly marked
for no serialization or deserialization. In order to to check
for every layer of nesting, I moved the noserde check to the
recursive layer from the original top-level function. This
mimics how it correctly works in decoding
@isaiahvita isaiahvita requested a review from a team as a code owner October 21, 2022 16:22

func (e *Encoder) unsupportedType(v interface{}) error {
if document.IsNoSerde(v) {
return &document.InvalidUnmarshalError{Type: reflect.TypeOf(v)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skmcgrail is this backwards incompatible? should i be performing the same error behavior as L24?

Comment on lines -23 to -26
if document.IsNoSerde(v) {
return nil, fmt.Errorf("unsupported type: %v", v)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this check should stay? Otherwise I think lines 71-78 in the encode function could still serialize the zero value of a generated Smithy type as an empty object which would be weird?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my previous implementation, the document.IsNoSerde func was still being called, i had just wrapped it in another function isUnsupported. however, in my latest commit, I replaced that to more closely mimic decode which actually directly calls document.IsNoSerde when decoding a struct

@isaiahvita isaiahvita merged commit a308d23 into aws:main Oct 21, 2022
@isaiahvita isaiahvita deleted the isvita/issues-391 branch February 21, 2023 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants