Skip to content

Conversation

@Nagato-Yuzuru
Copy link

Ensure response body is decoded to UTF-8 when raising ResponseException,

Ensure response body is decoded to UTF-8 when raising ResponseException,
@Nagato-Yuzuru
Copy link
Author

Nagato-Yuzuru commented Jul 28, 2025

支付异常抛出的时候尝试拿到response内容,标准库签名如下:

 http.client.HTTPResponse
def read(self, amt: int | None = None) -> bytes

Read and return the response body, or up to the next amt bytes.

报错信息

.venv/lib/python3.13/site-packages/alipay/aop/api/util/WebUtils.py:148

    raise ResponseException('[' + THREAD_LOCAL.uuid + ']invalid http status ' + str(response.status) + \
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                           ',detail body:' + response.read())
                           ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "bytes") to str

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.

1 participant