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

Latest Goa fails to codegen nested ResultType when Extend() is used #3598

Open
smessier opened this issue Sep 27, 2024 · 0 comments
Open

Latest Goa fails to codegen nested ResultType when Extend() is used #3598

smessier opened this issue Sep 27, 2024 · 0 comments

Comments

@smessier
Copy link
Contributor

See file attachment for API that demonstrates the issue.
foo.zip

We have had to change from using Type to ResultType for media with multiple views since Type no longer allows views after goa v3.17
Changing to ResultType exposes a weird issue having to do with nesting and extending ResultType. when top-level media includes a field that has an extended ResultType then the deepest ResultType fails to codegen properly in "foo/gen/http/bar/client/encode_decode.go" and "foo/gen/http/bar/server/encode_decode.go". the bug is the same in both cases:

// marshalBarviewsImmediateChildExtenderViewToImmediateChildExtenderResponseBody
// builds a value of type *ImmediateChildExtenderResponseBody from a value of
// type *barviews.ImmediateChildExtenderView.
func marshalBarviewsImmediateChildExtenderViewToImmediateChildExtenderResponseBody(v *barviews.ImmediateChildExtenderView) *ImmediateChildExtenderResponseBody {
	if v == nil {
		return nil
	}
	res := &ImmediateChildExtenderResponseBody{
		ID:   *v.ID,
		Name: *v.Name,
		More: v.More,
	}
	if v.DeepChild != nil {
		res.DeepChild = marshalBarviewsDeepChildToDeepChildResponseBody(v.DeepChild)  <--- wrong function name, missing "View"
	}

	return res
}

// marshalBarviewsDeepChildViewToDeepChildResponseBody builds a value of type
// *DeepChildResponseBody from a value of type *barviews.DeepChildView.
func marshalBarviewsDeepChildViewToDeepChildResponseBody(v *barviews.DeepChildView) *DeepChildResponseBody {
	if v == nil {
		return nil
	}
	res := &DeepChildResponseBody{
		ID:   *v.ID,
		Name: *v.Name,
	}

	return res
}

Note that this bug appears to have been present for many previous versions but is only seen when forced to change from using Type to ResultType. Not sure if having multiple views are required to reproduce but our use case has them.

Example of codegen:

~/gopath/src/foo$ goa version
Goa version v3.19.1
~/gopath/src/foo$ goa gen foo/design
gen/bar/client.go
...
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

No branches or pull requests

1 participant