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
Conversation
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
document/json/encoder.go
Outdated
|
||
func (e *Encoder) unsupportedType(v interface{}) error { | ||
if document.IsNoSerde(v) { | ||
return &document.InvalidUnmarshalError{Type: reflect.TypeOf(v)} |
There was a problem hiding this comment.
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?
if document.IsNoSerde(v) { | ||
return nil, fmt.Errorf("unsupported type: %v", v) | ||
} | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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.