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

document.NoSerde is not checked for nesteted types. #391

Closed
skmcgrail opened this issue Oct 5, 2022 · 0 comments
Closed

document.NoSerde is not checked for nesteted types. #391

skmcgrail opened this issue Oct 5, 2022 · 0 comments
Assignees
Labels
bug This issue is a bug.

Comments

@skmcgrail
Copy link
Member

When marshalling a Go type to a document type it was discovered that the document.IsNoSerde check to determine whether a type is a generated Go type defined in the Smithy model only validates the passed in shape. In this updated test snippet below, it is shown that a custom user defined Go type using a generated type as a field does not correctly prevent usage of the generated type.

func TestNewEncoderUnsupportedTypes(t *testing.T) {
	type customTime time.Time
	type noSerde = document.NoSerde
	type NestedThing struct {
		SomeThing string
		noSerde
	}
	type Thing struct {
		OtherThing  string
		NestedThing NestedThing
	}

	cases := []interface{}{
		time.Now().UTC(),
		customTime(time.Now().UTC()),
		Thing{OtherThing: "cool", NestedThing: NestedThing{SomeThing: "thing"}},
	}

	encoder := json.NewEncoder()
	for _, tt := range cases {
		_, err := encoder.Encode(tt)
		if err == nil {
			t.Errorf("expect error, got nil")
		}
	}
}

IsNoSerde check should be validated for any type that is nested. So usages in fields, or as slice types, or map types etc.

@skmcgrail skmcgrail added the bug This issue is a bug. label Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants