Skip to content

fix: handle response status code-based errors in ApiRepo.info before deserialization#109

Merged
Narsil merged 1 commit into
huggingface:mainfrom
shadeMe:fix/repo_info_raise_for_status
Jun 10, 2025
Merged

fix: handle response status code-based errors in ApiRepo.info before deserialization#109
Narsil merged 1 commit into
huggingface:mainfrom
shadeMe:fix/repo_info_raise_for_status

Conversation

@shadeMe

@shadeMe shadeMe commented Jun 10, 2025

Copy link
Copy Markdown
Contributor

Currently, deserialization is immediately attempted after receiving a response from the remote server without checking its validity. This results in inscrutable errors like request error: error decoding response body when the returned response has a non-2XX status code and the ApiError value is propagated upward. This PR addresses this by calling the error_for_status() method before json().

On a related note, it might be worth updating ApiBuilder to either raise an error when an empty authentication token is passed to it or, alternatively, to skip the authorization key in the header when the token's empty.

…e deserialization

Currently, deserialization is immediately attempted after receiving a response
from the remote server without checking its validity. This results in inscrutable
errors like `request error: error decoding response body` when the returned
response has a non-2XX status code and the `ApiError` value is propagated upward.

@Narsil Narsil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this !

@Narsil Narsil merged commit ee5f661 into huggingface:main Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants