HTTP node fails to parse simple JSON Body #12855

Closed
opened 2026-02-21 19:09:23 -05:00 by yindo · 5 comments
Owner

Originally created by @lilacs2039 on GitHub (Apr 13, 2025).

Originally assigned to: @crazywoola on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.2.0

Cloud or Self Hosted

Cloud

Steps to reproduce

Use the public endpoint to execute a request equivalent to the following curl command in the HTTP node:

curl -X POST "https://httpbin.org/post" \
  -H "Content-Type: application/json" \
  -H "accept: application/json" \
  -d '{
    "foo": "bar"
    }'

✔️ Expected Behavior

You get a response equivalent to:

{
  "args": {},
  "data": "{\"foo\": \"bar\"}",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "application/json",
    "Content-Length": "14",
    "Content-Type": "application/json",
    "Host": "httpbin.org",
    "User-Agent": "curl/7.81.0",
    "X-Amzn-Trace-Id": "…"
  },
  "json": {
    "foo": "bar"
  },
  "origin": "x.x.x.x",
  "url": "https://httpbin.org/post"
}

Actual Behavior

JSON parsing fails.

Image

Success if whitespace is completely removed

Image

Related issues

https://github.com/langgenius/dify/issues/15367
https://github.com/langgenius/dify/pull/12761
https://github.com/langgenius/dify/issues/12759
https://github.com/langgenius/dify/discussions/9836
https://github.com/langgenius/dify/issues/6684

Originally created by @lilacs2039 on GitHub (Apr 13, 2025). Originally assigned to: @crazywoola on GitHub. ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.2.0 ### Cloud or Self Hosted Cloud ### Steps to reproduce Use the public endpoint to execute a request equivalent to the following curl command in the HTTP node: ``` curl -X POST "https://httpbin.org/post" \ -H "Content-Type: application/json" \ -H "accept: application/json" \ -d '{ "foo": "bar" }' ``` ### ✔️ Expected Behavior You get a response equivalent to: ``` { "args": {}, "data": "{\"foo\": \"bar\"}", "files": {}, "form": {}, "headers": { "Accept": "application/json", "Content-Length": "14", "Content-Type": "application/json", "Host": "httpbin.org", "User-Agent": "curl/7.81.0", "X-Amzn-Trace-Id": "…" }, "json": { "foo": "bar" }, "origin": "x.x.x.x", "url": "https://httpbin.org/post" } ``` ### ❌ Actual Behavior JSON parsing fails. ![Image](https://github.com/user-attachments/assets/e3df2bd3-5f24-4249-a079-34719dbfa17a) Success if whitespace is completely removed ![Image](https://github.com/user-attachments/assets/98852b95-fb73-4746-92ab-d20e09f80de8) ### Related issues https://github.com/langgenius/dify/issues/15367 https://github.com/langgenius/dify/pull/12761 https://github.com/langgenius/dify/issues/12759 https://github.com/langgenius/dify/discussions/9836 https://github.com/langgenius/dify/issues/6684
yindo added the 🐞 bug label 2026-02-21 19:09:23 -05:00
yindo closed this issue 2026-02-21 19:09:23 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 13, 2025):

I found a similar unsolved discussion regarding JSON parsing issues in the HTTP tool, where JSON can only accept strings, leading to problems with escape characters in the JSON string processed by the code [1].

For your issue, it seems like the HTTP node is not correctly parsing the JSON body as expected. You might want to check if the Content-Type header is correctly set to application/json and ensure that the JSON body is formatted properly. The HTTP node should handle Content-Type: application/json headers by setting the header correctly and processing the body as JSON [2][3].

If the issue persists, consider reviewing the error handling configuration in the HTTP node, which allows for retry strategies and other error management options [4][5][6].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Apr 13, 2025): <!-- Answer --> I found a similar unsolved discussion regarding JSON parsing issues in the HTTP tool, where JSON can only accept strings, leading to problems with escape characters in the JSON string processed by the code <sup>[[1]](https://github.com/langgenius/dify/discussions/13768)</sup>. For your issue, it seems like the HTTP node is not correctly parsing the JSON body as expected. You might want to check if the `Content-Type` header is correctly set to `application/json` and ensure that the JSON body is formatted properly. The HTTP node should handle `Content-Type: application/json` headers by setting the header correctly and processing the body as JSON <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/tests/unit_tests/core/workflow/nodes/http_request/test_http_request_executor.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/http_request/executor.py)</sup>. If the issue persists, consider reviewing the error handling configuration in the HTTP node, which allows for retry strategies and other error management options <sup>[[4]](https://github.com/langgenius/dify-docs/blob/main/en/guides/workflow/node/http-request.md)</sup><sup>[[5]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/workflow/error-handling/README.md)</sup><sup>[[6]](https://github.com/langgenius/dify-docs/blob/main/jp/guides/workflow/node/http-request.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/ae831e7c-d8bd-467b-8235-42ced2bb0311?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/ae831e7c-d8bd-467b-8235-42ced2bb0311?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/ae831e7c-d8bd-467b-8235-42ced2bb0311?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/ae831e7c-d8bd-467b-8235-42ced2bb0311?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ae831e7c-d8bd-467b-8235-42ced2bb0311?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/ae831e7c-d8bd-467b-8235-42ced2bb0311?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ae831e7c-d8bd-467b-8235-42ced2bb0311?feedback_type=other)</sup>
Author
Owner

@TakumaKira commented on GitHub (Apr 14, 2025):

@lilacs2039

I tried dozens of requests to reproduce this. I could see the same error at first, but it mysteriously disappeared while I was trying to fix it.

Then, I found a possible cause: Didn't you include full-width space in the request body? Only this could reproduce the issue in 10 out of 10 trials, as full-width space is invalid character in json string.

@TakumaKira commented on GitHub (Apr 14, 2025): @lilacs2039 I tried dozens of requests to reproduce this. I could see the same error at first, but it mysteriously disappeared while I was trying to fix it. Then, I found a possible cause: Didn't you include full-width space in the request body? Only this could reproduce the issue in 10 out of 10 trials, as full-width space is invalid character in json string.
Author
Owner

@lilacs2039 commented on GitHub (Apr 14, 2025):

@TakumaKira

Didn't you include full-width space in the request body?

I got the JSON from the execution history "TestRun #10" . As shown below, it did not contain any full-width spaces.

{
  "foo":"bar"
}

Image

Mysteriously, when I tried it today, the error disappeared in my environment too.

@lilacs2039 commented on GitHub (Apr 14, 2025): @TakumaKira > Didn't you include full-width space in the request body? I got the JSON from the execution history "TestRun #10" . As shown below, it did not contain any full-width spaces. ``` { "foo":"bar" } ``` ![Image](https://github.com/user-attachments/assets/a507e536-e786-4a1f-9272-2257274697cc) Mysteriously, when I tried it today, the error disappeared in my environment too.
Author
Owner

@TakumaKira commented on GitHub (Apr 14, 2025):

For the record, the error would come from this line:

https://github.com/langgenius/dify/blob/9f8947f1ddde696c43674ecef57e8281eb881a16/api/core/workflow/nodes/http_request/executor.py#L178

I'm not really sure what happened there, but it would come from json library.

If it actually caused the error only with half-width spaces(as @lilacs2039 and me might observe), the behavior seems to be related to cache-wise logic somewhere under the hood.

@TakumaKira commented on GitHub (Apr 14, 2025): For the record, the error would come from this line: https://github.com/langgenius/dify/blob/9f8947f1ddde696c43674ecef57e8281eb881a16/api/core/workflow/nodes/http_request/executor.py#L178 I'm not really sure what happened there, but it would come from [json](https://docs.python.org/3/library/json.html) library. If it actually caused the error only with half-width spaces(as @lilacs2039 and me might observe), the behavior seems to be related to cache-wise logic somewhere under the hood.
Author
Owner

@crazywoola commented on GitHub (Jul 3, 2025):

Image

I can not reproduce this error any longer. :)

@crazywoola commented on GitHub (Jul 3, 2025): ![Image](https://github.com/user-attachments/assets/7531d6e5-50df-439c-bcb9-a9372ee6ce7c) I can not reproduce this error any longer. :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12855