Crash with POST requests and WebTestClient: Request body incomplete.
See original GitHub issueHi.
I’m getting the following crash
java.lang.IllegalArgumentException: Request body incomplete.
at org.springframework.util.Assert.isTrue(Assert.java:116)
at org.springframework.test.web.reactive.server.ExchangeResult.getRequestBodyContent(ExchangeResult.java:149)
at org.springframework.restdocs.webtestclient.WebTestClientRequestConverter.convert(WebTestClientRequestConverter.java:73)
at org.springframework.restdocs.webtestclient.WebTestClientRequestConverter.convert(WebTestClientRequestConverter.java:60)
at org.springframework.restdocs.generate.RestDocumentationGenerator.handle(RestDocumentationGenerator.java:199)
at org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.lambda$document$0(WebTestClientRestDocumentation.java:81)
at org.springframework.test.web.reactive.server.DefaultWebTestClient$DefaultBodyContentSpec.lambda$consumeWith$2(DefaultWebTestClient.java:496)
at org.springframework.test.web.reactive.server.ExchangeResult.assertWithDiagnostics(ExchangeResult.java:194)
at org.springframework.test.web.reactive.server.DefaultWebTestClient$DefaultBodyContentSpec.consumeWith(DefaultWebTestClient.java:496)
at MyTest.testMain(MyTest.java:72)
The issue is related with the use of a request body with a post request.
This happens due to an assert Assert.isTrue(MonoProcessor.isTerminated()
. Inspecting that method isTerminated
returns subscribers == TERMINATED
, but in the case of the request body, debugging shows that subscribers == EMPTY
.
Testcase follows.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Spring WebClient Post method Body - Stack Overflow
Here's what i've tried to do but it gives me HTTP code 500. Most likely because you're sending the wrong data in a...
Read more >Spring 5 WebClient and WebTestClient Tutorial with Examples
WebClient is a non-blocking, reactive HTTP client with a fluent functional style API. ... Passing Request Body in WebClient requests.
Read more >WebTestClient gets 404 on Spring Boot 2.4.0-M3 while works ...
Coding example for the question WebTestClient gets 404 on Spring Boot 2.4.0-M3 ... If you want to be able to make POST requests...
Read more >spring-projects/spring-boot - Gitter
Hey I have a spring boot webflux (2.2.7) app running on k8s. It will from time to time receive 10-100 rest call at...
Read more >Changelog | Pact Docs
4.3.0-beta.2 - Support plugin data in pact files + fixes from master ... a84d47a09 - feat: Ignore missing part content type headers with ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I finally pinpointed the problem: the class
WiretapConnector.WiretapClientHttpRequest
caches the request body, which is then relayed to the rest docs code. If the request body is not injected into the@RequestMapping
, then the original publisher is never written and theMonoProcessor
never reaches the terminated state.This fixes the test case
Ok. Thanks for the input. Cheers.
PS: One of the very last classes in the stack is
org.springframework.restdocs.webtestclient.WebTestClientRequestConverter
so I asked about the error message.