Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(http_request): add error handling for invalid URLs #12082

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/core/workflow/nodes/http_request/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ class ResponseSizeError(HttpRequestNodeError):

class RequestBodyError(HttpRequestNodeError):
"""Raised when the request body is invalid."""


class InvalidURLError(HttpRequestNodeError):
"""Raised when the URL is invalid."""
7 changes: 7 additions & 0 deletions api/core/workflow/nodes/http_request/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
FileFetchError,
HttpRequestNodeError,
InvalidHttpMethodError,
InvalidURLError,
RequestBodyError,
ResponseSizeError,
)
Expand Down Expand Up @@ -66,6 +67,12 @@ def __init__(
node_data.authorization.config.api_key
).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.method = node_data.method
self.auth = node_data.authorization
Expand Down
Loading