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

Response struct without a "Body" field is silently ignored if using Register #481

Open
RangelReale opened this issue Jun 14, 2024 · 1 comment

Comments

@RangelReale
Copy link

If we register an operation where the output struct don't have a "Body" field, the output is completely ignored and nothing is written to the http connection.

This is a surprising behavior, maybe Register should panic if the output structure don't have this field? This will for sure generate nasty bugs in big codebases.

@outofthisworld
Copy link

outofthisworld commented Jun 15, 2024

If we register an operation where the output struct don't have a "Body" field, the output is completely ignored and nothing is written to the http connection.

This is a surprising behavior, maybe Register should panic if the output structure don't have this field? This will for sure generate nasty bugs in big codebases.

Also just to add to this, all of the fields in the struct will automatically become 'headers'. Which you can see in the docs

In addition, returning nil as a response body causes the package to error due to some Serialization issue. Now you could argue you should be instead returning No Content, however I don't necessarily agree because you could be expecting a pointer to something, return it, oops accidently nil and then get a 500.

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

2 participants