Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(http_request): handle empty and string data inputs (#9579)

-LAN-38a4f0234ddc
diff --git a/api/core/workflow/nodes/http_request/entities.py b/api/core/workflow/nodes/http_request/entities.py
index 816ece9577a..dec76a277e0 100644
--- a/api/core/workflow/nodes/http_request/entities.py
+++ b/api/core/workflow/nodes/http_request/entities.py
@@ -1,5 +1,5 @@
from collections.abc import Sequence
-from typing import Literal, Optional
+from typing import Any, Literal, Optional
import httpx
from pydantic import BaseModel, Field, ValidationInfo, field_validator
@@ -52,6 +52,16 @@ class HttpRequestNodeBody(BaseModel):
type: Literal["none", "form-data", "x-www-form-urlencoded", "raw-text", "json", "binary"]
data: Sequence[BodyData] = Field(default_factory=list)
+ @field_validator("data", mode="before")
+ @classmethod
+ def check_data(cls, v: Any):
+ """For compatibility, if body is not set, return empty list."""
+ if not v:
+ return []
+ if isinstance(v, str):
+ return [BodyData(key="", type="text", value=v)]
+ return v
+
class HttpRequestNodeTimeout(BaseModel):
connect: int = dify_config.HTTP_REQUEST_MAX_CONNECT_TIMEOUT