Use .IsLegacyEmptyRequest instead of checking that .Request is nil in codegen#3098
Conversation
pietern
left a comment
There was a problem hiding this comment.
Can you revert the changes to .github and remove tagging.py?
We use a different location for tagging.py and don't use the NEXT_CHANGELOG detector.
2f15d60 to
86e842a
Compare
| func newList() *cobra.Command { | ||
| cmd := &cobra.Command{} | ||
|
|
||
| // TODO: short flags |
There was a problem hiding this comment.
Why are these comments being added? Do you need to rebase?
There was a problem hiding this comment.
Because the TODO depends on the request being null, and it is never null from now on. It is just not rendered for legacy requests.
Line 149 in 37d2683
shreyas-goenka
left a comment
There was a problem hiding this comment.
The template changes look good to me. We need to fix the // TODO being added though.
| var {{.CamelName}}Overrides []func( | ||
| *cobra.Command, | ||
| {{- if .Request }} | ||
| {{- if not .IsLegacyEmptyRequest }} |
There was a problem hiding this comment.
Can you explain the semantics of .IsLegacyEmptyRequest in the PR description? For which fields will it be set.
37d2683 to
379fe40
Compare
.IsLegacyEmptyRequest instead of checking that .Request is nil in codegen
Changes
Changes because of always defining request messages. There is a bug in the Code Generator that sets the request to nil if it has no fields. As we fix the generator, it changes the generated code. To keep the generated code the same, we need to add exceptions for already existing requests.
IsLegacyEmptyRequest returns true if the request has no fields and, for the above reason, is not rendered in the SDK.
This PR also removes TODO from the template, which adds noise to the diff. Also, we don't need it to remind us to implement short flags.
Why
We made a few changes in the Code generator that ensure that the request can never be nil. However, we cannot add the request to the existing interface. So, adding an exception for legacy commands.
Tests
Existing CI. Manually verified this change, only changed a few comments.