goa
goa copied to clipboard
Latest Goa fails to codegen nested ResultType when Extend() is used
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
...