mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 19:36:53 +08:00
fix(http_request): add error handling for invalid URLs (#12082)
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
@@ -20,3 +20,7 @@ class ResponseSizeError(HttpRequestNodeError):
|
|||||||
|
|
||||||
class RequestBodyError(HttpRequestNodeError):
|
class RequestBodyError(HttpRequestNodeError):
|
||||||
"""Raised when the request body is invalid."""
|
"""Raised when the request body is invalid."""
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidURLError(HttpRequestNodeError):
|
||||||
|
"""Raised when the URL is invalid."""
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from .exc import (
|
|||||||
FileFetchError,
|
FileFetchError,
|
||||||
HttpRequestNodeError,
|
HttpRequestNodeError,
|
||||||
InvalidHttpMethodError,
|
InvalidHttpMethodError,
|
||||||
|
InvalidURLError,
|
||||||
RequestBodyError,
|
RequestBodyError,
|
||||||
ResponseSizeError,
|
ResponseSizeError,
|
||||||
)
|
)
|
||||||
@@ -66,6 +67,12 @@ class Executor:
|
|||||||
node_data.authorization.config.api_key
|
node_data.authorization.config.api_key
|
||||||
).text
|
).text
|
||||||
|
|
||||||
|
# check if node_data.url is a valid URL
|
||||||
|
if not node_data.url:
|
||||||
|
raise InvalidURLError("url is required")
|
||||||
|
if not node_data.url.startswith(("http://", "https://")):
|
||||||
|
raise InvalidURLError("url should start with http:// or https://")
|
||||||
|
|
||||||
self.url: str = node_data.url
|
self.url: str = node_data.url
|
||||||
self.method = node_data.method
|
self.method = node_data.method
|
||||||
self.auth = node_data.authorization
|
self.auth = node_data.authorization
|
||||||
|
|||||||
Reference in New Issue
Block a user