Skip to content

Commit 1b81a7c

Browse files
authored
fix(blocks): Error messages from SendWebRequestBlock use the requested translated IP instead of the orignal URL (#10009)
### Changes 🏗️ Keep the original URL when an HTTP error occurs in `SendWebRequestBlock`. ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Test sending POST request on a web that doesn't support POST request using `SendWebRequestBlock`.
1 parent 8f1b3eb commit 1b81a7c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

autogpt_platform/backend/backend/util/request.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def request(
247247

248248
# Pin the URL if untrusted
249249
hostname = url.hostname
250+
original_url = url.geturl()
250251
if not is_trusted:
251252
url = pin_url(url, ip_addresses)
252253

@@ -277,6 +278,12 @@ def request(
277278
**kwargs,
278279
)
279280

281+
# Replace response URLs with the original host for clearer error messages
282+
if url.hostname != hostname:
283+
response.url = original_url
284+
if response.request is not None:
285+
response.request.url = original_url
286+
280287
if self.raise_for_status:
281288
response.raise_for_status()
282289

0 commit comments

Comments
 (0)