From 7d80387a817561995bce159d02e85bd58469fad8 Mon Sep 17 00:00:00 2001 From: "Yu, Guangye" Date: Fri, 24 Jul 2026 21:19:58 +0000 Subject: [PATCH] Fix AttributeError on secondary rate limit check in arest --- src/ghstack/github_real.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ghstack/github_real.py b/src/ghstack/github_real.py index 042d38a..9cfb1aa 100644 --- a/src/ghstack/github_real.py +++ b/src/ghstack/github_real.py @@ -224,12 +224,11 @@ async def arest(self, method: str, path: str, **kwargs: Any) -> Any: async with getattr(session, method)(url, **request_kwargs) as resp: logging.debug("%s response status: %s", log_prefix, resp.status) + resp_text = await resp.text() try: - r = await resp.json() - except (aiohttp.ContentTypeError, ValueError): - logging.debug( - "%s response body:\n%s", log_prefix, await resp.text() - ) + r = json.loads(resp_text) + except ValueError: + logging.debug("%s response body:\n%s", log_prefix, resp_text) raise else: pretty_json = json.dumps(r, indent=1) @@ -251,7 +250,7 @@ async def arest(self, method: str, path: str, **kwargs: Any) -> Any: # GitHub doesn't document the content of these messages, but this # seems to be an accurate way to find secondary rate limits. Any # other reason for 403 or 429 will fall through to the error below. - elif b"rate limit" in resp.content.lower(): + elif "rate limit" in resp_text.lower(): retry_after_seconds = resp.headers.get("retry-after") if retry_after_seconds: sleep_time = int(retry_after_seconds)