Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(blocks): Error messages from SendWebRequestBlock use the requested translated IP instead of the orignal URL (#10009)

Zamil Majdy1b81a7c755ab
diff --git a/autogpt_platform/backend/backend/util/request.py b/autogpt_platform/backend/backend/util/request.py
index 9086e779c6..4dfd32a12a 100644
--- a/autogpt_platform/backend/backend/util/request.py
+++ b/autogpt_platform/backend/backend/util/request.py
@@ -247,6 +247,7 @@ class Requests:
# Pin the URL if untrusted
hostname = url.hostname
+ original_url = url.geturl()
if not is_trusted:
url = pin_url(url, ip_addresses)
@@ -277,6 +278,12 @@ class Requests:
**kwargs,
)
+ # Replace response URLs with the original host for clearer error messages
+ if url.hostname != hostname:
+ response.url = original_url
+ if response.request is not None:
+ response.request.url = original_url
+
if self.raise_for_status:
response.raise_for_status()