From 666e33fa631a007e4daebd6361cafa394de9c3bb Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 9 Jan 2026 16:13:17 -0700 Subject: [PATCH] fix(blocks): enable WordPress API error handling with raise_for_status=False The Requests class defaults to raise_for_status=True, which raises exceptions for 4xx/5xx responses before custom error handling code can execute. This made the error parsing logic unreachable dead code. Now all WordPress API functions properly return responses for all HTTP status codes, allowing extraction of detailed error messages from the WordPress API JSON response body. Co-Authored-By: Claude Opus 4.5 --- .../backend/backend/blocks/wordpress/_api.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/wordpress/_api.py b/autogpt_platform/backend/backend/blocks/wordpress/_api.py index 9107379e20..d21dc3e05d 100644 --- a/autogpt_platform/backend/backend/blocks/wordpress/_api.py +++ b/autogpt_platform/backend/backend/blocks/wordpress/_api.py @@ -161,7 +161,7 @@ async def oauth_exchange_code_for_tokens( grant_type="authorization_code", ).model_dump(exclude_none=True) - response = await Requests().post( + response = await Requests(raise_for_status=False).post( f"{WORDPRESS_BASE_URL}oauth2/token", headers=headers, data=data, @@ -205,7 +205,7 @@ async def oauth_refresh_tokens( grant_type="refresh_token", ).model_dump(exclude_none=True) - response = await Requests().post( + response = await Requests(raise_for_status=False).post( f"{WORDPRESS_BASE_URL}oauth2/token", headers=headers, data=data, @@ -252,7 +252,7 @@ async def validate_token( "token": token, } - response = await Requests().get( + response = await Requests(raise_for_status=False).get( f"{WORDPRESS_BASE_URL}oauth2/token-info", params=params, ) @@ -296,7 +296,7 @@ async def make_api_request( url = f"{WORDPRESS_BASE_URL.rstrip('/')}{endpoint}" - request_method = getattr(Requests(), method.lower()) + request_method = getattr(Requests(raise_for_status=False), method.lower()) response = await request_method( url, headers=headers, @@ -484,7 +484,7 @@ async def create_post( "Content-Type": "application/x-www-form-urlencoded", } - response = await Requests().post( + response = await Requests(raise_for_status=False).post( f"{WORDPRESS_BASE_URL.rstrip('/')}{endpoint}", headers=headers, data=data, @@ -613,7 +613,7 @@ async def get_posts( if status: params["status"] = status.value - response = await Requests().get( + response = await Requests(raise_for_status=False).get( f"{WORDPRESS_BASE_URL.rstrip('/')}{endpoint}", headers=headers, params=params,