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

Make empty body configurable behaviour #10810

Open
CezaryBD opened this issue May 8, 2024 · 8 comments
Open

Make empty body configurable behaviour #10810

CezaryBD opened this issue May 8, 2024 · 8 comments
Labels
type: improvement A minor improvement to an existing feature

Comments

@CezaryBD
Copy link

CezaryBD commented May 8, 2024

Expected Behavior

It should be configurable if fail or pass the response.

Actual Behaviour

ab5c4a2#diff-af18b3b8347409fdb81dedda7689f9d13c962d129830818e2dbd4c48770ddecdR151
Line #166.
This change introduces a default behaviour that I would prefer to be configurable.
An empty body on 200 OK status is not an error :)

Steps To Reproduce

No response

Environment Information

No response

Example Application

https://github.com/CezaryBD/micronaut-reactor-mono-void-bug-01/blob/main/src/test/java/com/example/DemoTest.java

Version

4.3.3

@sdelamo
Copy link
Collaborator

sdelamo commented May 8, 2024

@CezaryBD for an empty body I think a 204 response would be more idiomatic.

@CezaryBD
Copy link
Author

CezaryBD commented May 8, 2024

@sdelamo depends on the approach, but generally, yes - 204 would be a much better solution.

@yawkat
Copy link
Member

yawkat commented May 13, 2024

That change did not introduce empty behavior, it added an exception message for decoding failures.

What would you like to happen when the body is empty? We can't decode it as json.

@CezaryBD
Copy link
Author

I think if the status code > 200, then no exception should be fired, cause this can be an expected behaviour.

@yawkat
Copy link
Member

yawkat commented May 14, 2024

For status codes >=400 we already have exception-on-error-status.

For 2xx with empty body, we can't parse the body as json, so there is no sensible default to return. We must throw

@CezaryBD
Copy link
Author

CezaryBD commented May 14, 2024

Pardon my manners, example app was not included in the ticket description.
Sorry for asking, but why do you need to throw? It seems to me, that I will need to create a little boilerplate every time I need to return an empty body, because micronaut-reactor cannot handle it. I see that Spring's WebFlux is doing the same.
204 with empty body is no error: https://datatracker.ietf.org/doc/html/rfc9110#name-204-no-content

@yawkat
Copy link
Member

yawkat commented May 15, 2024

ah, you want an empty mono? that would indeed be a reasonable value. i was thinking of the blocking case.

@yawkat yawkat added the type: improvement A minor improvement to an existing feature label May 15, 2024
@CezaryBD
Copy link
Author

empty Mono should be passed just fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants