csurong opened a new issue, #18687:
URL: https://github.com/apache/dolphinscheduler/issues/18687

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   HTTP tasks lose the actual response body when the endpoint returns a status 
other than 200. This affects supported configurations such as a POST request 
with a custom success status of 201, or a body-content check on a 202 response.
   
   For example, an endpoint returns:
   
   ```http
   HTTP/1.1 201 Created
   Content-Type: application/json
   
   {"id":42,"status":"created"}
   ```
   
   With the task's custom status set to 201, the task succeeds, but the body in 
its response output is replaced with:
   
   ```text
   Request execute failed, httpCode: 201, httpBody: 
okhttp3.internal.http.RealResponseBody@...
   ```
   
   The returned ID is therefore unavailable in the task output. Similarly, a 
202 response containing `{"id":42,"status":"queued"}` fails a BODY_CONTAINS 
check for `queued`.
   
   ### What you expected to happen
   
   Preserve the endpoint's actual response body independently of its status 
code. Apply the configured status-code or body-content validation to the 
received response.
   
   ### How to reproduce
   
   1. Use an HTTP endpoint that responds to POST with status 201 and body 
`{"id":42,"status":"created"}`.
   2. Configure an HTTP task with that URL, method POST, a nonempty JSON body 
such as `{"name":"report"}`, and custom response-code validation set to 201.
   3. Run the task and inspect the body in its response output: the task 
succeeds, but the JSON is replaced with the text above.
   4. Alternatively, return status 202 and body `{"id":42,"status":"queued"}`, 
and select BODY_CONTAINS with condition `queued`. The task fails despite the 
matching response body.
   
   Both cases were reproduced through HttpTask.init/handle using a local 
MockWebServer HTTP connection. The task execution context was mocked; a full 
deployed workflow was not used.
   
   ### Anything else
   
   dev at 974271457b9b958049fbe3fc07215381a24cb058.
   
   OkHttpUtils.getResponseBody reads ResponseBody.string() only when 
response.code() equals 200. For other statuses it formats the ResponseBody 
object into an error string. HttpTask then uses that replacement for both 
output parameters and body checks.
   
   ### Version
   
   dev
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to