Skip to content

Commit 80e18cb

Browse files
committed
fix: omit error-check for 201 responses in async_call_api
Skip error-checking for responses with a 201 status code in async_call_api, preventing false error raises for successful REST operations.
1 parent 8bb42b7 commit 80e18cb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

aiogithubapi/client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,13 @@ async def async_call_api(
181181
if exception := STATUS_EXCEPTIONS.get(response.status):
182182
raise exception(message or response.data)
183183

184-
if isinstance(response.data, dict):
185-
if message is not None:
186-
if exception := MESSAGE_EXCEPTIONS.get(message):
187-
raise exception(message)
188-
raise GitHubException(message)
184+
# For a 201 Created response, we assume the operation was successful and ignore any "message" field.
185+
if not response.status == HttpStatusCode.CREATED:
186+
if isinstance(response.data, dict):
187+
if message is not None:
188+
if exception := MESSAGE_EXCEPTIONS.get(message):
189+
raise exception(message)
190+
raise GitHubException(message)
189191

190192
if endpoint == "/graphql" and response.data.get("errors", []):
191193
raise GitHubGraphQLException(

0 commit comments

Comments
 (0)