René's URL Explorer Experiment


Title: fix: avoid TypeError when a 403 error body is a JSON array by kwy404 · Pull Request #2829 · googleapis/google-api-python-client · GitHub

Open Graph Title: fix: avoid TypeError when a 403 error body is a JSON array by kwy404 · Pull Request #2829 · googleapis/google-api-python-client

X Title: fix: avoid TypeError when a 403 error body is a JSON array by kwy404 · Pull Request #2829 · googleapis/google-api-python-client

Description: Root cause _should_retry_response handles two shapes of 403 error bodies. The dict branch reads the reason from data["error"]["errors"][0]["reason"], but the list branch (bodies like [{"error": {...}}], the format reported in #225) reads data[0]["error"]["errors"]["reason"]. errors is a list, so indexing it with "reason" raises TypeError. That exception is not in the caught tuple (UnicodeDecodeError, ValueError, KeyError), so it escapes HttpRequest.execute(): a list-wrapped rateLimitExceeded 403 is never retried, and any other list-wrapped 403 surfaces as TypeError: list indices must be integers or slices, not str instead of HttpError. from googleapiclient.http import _should_retry_response body = b'[{"error": {"code": 403, "errors": [{"reason": "rateLimitExceeded"}]}}]' _should_retry_response(403, body) # main: TypeError, this branch: True The existing test_no_retry_403_list_fails did not catch this because its LIST_NOT_CONFIGURED_RESPONSE fixture is not valid JSON (the object is missing its braces), so json.loads fails before the list branch runs. Fix Index the first entry of errors, the same way the dict branch does. One line in googleapiclient/http.py. The fixture gets its missing braces so the existing test really exercises the list branch. Test New test_retry_403_list_rate_limit: a list-wrapped rateLimitExceeded 403 followed by a 200 should retry once and return {}. Existing test_no_retry_403_list_fails, now with valid JSON: a list-wrapped accessNotConfigured 403 should raise HttpError without retrying. Before the fix both fail with TypeError: list indices must be integers or slices, not str. After the fix both pass, and the rest of the suite gives the same results as on main. Checklist Make sure to open an issue as a bug/issue before writing your code (no separate issue; the bug and a reproduction are above) Ensure the tests and linter pass (black and the CI flake8 selection are clean on the changed files) Code coverage does not decrease (if any source code was changed) Appropriate docs were updated (if necessary): not needed

Open Graph Description: Root cause _should_retry_response handles two shapes of 403 error bodies. The dict branch reads the reason from data["error"]["errors"][0]["reason"], but the list bran...

X Description: Root cause _should_retry_response handles two shapes of 403 error bodies. The dict branch reads the reason from data["error"]["errors"][0]["reason&q...

Opengraph URL: https://github.com/googleapis/google-api-python-client/pull/2829

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a16648bb-9d49-da17-9357-7fa8bb0fff0a
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBFC6:395091:3E9BA5:53E827:6B008BD3
html-safe-noncefa0a73a0760b7294fa80e981e6922641b7ed6fb83929d1845ebbc4c2b5df8507
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkM2OjM5NTA5MTozRTlCQTU6NTNFODI3OjZCMDA4QkQzIiwidmlzaXRvcl9pZCI6IjgzNjc2MTQ2NDQwMzM5ODEzOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9f3db48338ebe5c1ce4a95e83d4e05c08541328f8267b1910a8c0a2b8442c6a3
hovercard-subject-tagpull_request:4646086857
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/googleapis/google-api-python-client/pull/2829/files
twitter:imagehttps://avatars.githubusercontent.com/u/64209066?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/64209066?s=400&v=4
og:image:altRoot cause _should_retry_response handles two shapes of 403 error bodies. The dict branch reads the reason from data["error"]["errors"][0]["reason"], but the list bran...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonec710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/googleapis/google-api-python-client git https://github.com/googleapis/google-api-python-client.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id15749269
octolytics-dimension-repository_nwogoogleapis/google-api-python-client
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id15749269
octolytics-dimension-repository_network_root_nwogoogleapis/google-api-python-client
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasebe616a2a6ec1c609d6e002896dff5352d5c5f28b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/google-api-python-client/pull/2829/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-api-python-client%2Fpull%2F2829%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-api-python-client%2Fpull%2F2829%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=googleapis%2Fgoogle-api-python-client
Reloadhttps://github.com/googleapis/google-api-python-client/pull/2829/files
Reloadhttps://github.com/googleapis/google-api-python-client/pull/2829/files
Reloadhttps://github.com/googleapis/google-api-python-client/pull/2829/files
googleapishttps://github.com/googleapis
google-api-python-clienthttps://github.com/googleapis/google-api-python-client
Codehttps://github.com/googleapis/google-api-python-client
Issues18 (18)https://github.com/googleapis/google-api-python-client/issues
Pull requests39 (39)https://github.com/googleapis/google-api-python-client/pulls
Discussionshttps://github.com/googleapis/google-api-python-client/discussions
Actionshttps://github.com/googleapis/google-api-python-client/actions
Projectshttps://github.com/googleapis/google-api-python-client/projects
Security and qualityhttps://github.com/googleapis/google-api-python-client/security
Insightshttps://github.com/googleapis/google-api-python-client/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fgoogleapis%2Fgoogle-api-python-client%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgoogleapis%2Fgoogle-api-python-client%2Fissues%2Fnew%2Fchoose
kwy404https://github.com/kwy404
googleapis:mainhttps://github.com/googleapis/google-api-python-client/tree/main
kwy404:fix-403-list-error-reasonhttps://github.com/kwy404/google-api-python-client/tree/fix-403-list-error-reason
Conversation 4 https://github.com/googleapis/google-api-python-client/pull/2829
Commits 2 https://github.com/googleapis/google-api-python-client/pull/2829/commits
Checks 9 https://github.com/googleapis/google-api-python-client/pull/2829/checks
Files changed https://github.com/googleapis/google-api-python-client/pull/2829/files
Please reload this pagehttps://github.com/googleapis/google-api-python-client/pull/2829/files
fix: avoid TypeError when a 403 error body is a JSON array https://github.com/googleapis/google-api-python-client/pull/2829/files#top
Show all changes 2 commits https://github.com/googleapis/google-api-python-client/pull/2829/files
83a7067 fix: avoid TypeError when a 403 error body is a JSON array kwy404 Sep 26, 2026 https://github.com/googleapis/google-api-python-client/pull/2829/commits/83a7067b22610cf456e125d4a647d9ed07c23d15
8f66e36 fix: do not raise on malformed 403 error bodies kwy404 Sep 28, 2026 https://github.com/googleapis/google-api-python-client/pull/2829/commits/8f66e36d708b4e66a41fd5447a0adb9cfd61baf9
Clear filters https://github.com/googleapis/google-api-python-client/pull/2829/files
Please reload this pagehttps://github.com/googleapis/google-api-python-client/pull/2829/files
Please reload this pagehttps://github.com/googleapis/google-api-python-client/pull/2829/files
http.py https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-e492230da11e54b269c88852dc3b74a37cae746493f8d7ad91bc273ecf6b10fd
test_http.py https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-c004679546311e65d99f8cf55b34e6eadd4e7f59061e36d7875fec4a3bc0bc15
https://github.com/googleapis/google-api-python-client/blob/main/.github/CODEOWNERS#L8
googleapiclient/http.pyhttps://github.com/googleapis/google-api-python-client/pull/2829/files#diff-e492230da11e54b269c88852dc3b74a37cae746493f8d7ad91bc273ecf6b10fd
View file https://github.com/googleapis/google-api-python-client/blob/8f66e36d708b4e66a41fd5447a0adb9cfd61baf9/googleapiclient/http.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/googleapis/google-api-python-client/pull/2829/{{ revealButtonHref }}
https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-e492230da11e54b269c88852dc3b74a37cae746493f8d7ad91bc273ecf6b10fd
gemini-code-assisthttps://github.com/apps/gemini-code-assist
Sep 26, 2026https://github.com/googleapis/google-api-python-client/pull/2829/files#r4110803906
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://camo.githubusercontent.com/f9141739e81c5065c5f99ee945037104c1ba6def9f166570e17368344f990bdd/68747470733a2f2f7777772e677374617469632e636f6d2f636f64657265766965776167656e742f686967682d7072696f726974792e737667
Please reload this pagehttps://github.com/googleapis/google-api-python-client/pull/2829/files
kwy404https://github.com/kwy404
Sep 28, 2026https://github.com/googleapis/google-api-python-client/pull/2829/files#r4124382565
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/googleapis/google-api-python-client/pull/2829/files
https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-e492230da11e54b269c88852dc3b74a37cae746493f8d7ad91bc273ecf6b10fd
https://github.com/googleapis/google-api-python-client/blob/main/.github/CODEOWNERS#L8
tests/test_http.pyhttps://github.com/googleapis/google-api-python-client/pull/2829/files#diff-c004679546311e65d99f8cf55b34e6eadd4e7f59061e36d7875fec4a3bc0bc15
View file https://github.com/googleapis/google-api-python-client/blob/8f66e36d708b4e66a41fd5447a0adb9cfd61baf9/tests/test_http.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/googleapis/google-api-python-client/pull/2829/{{ revealButtonHref }}
https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-c004679546311e65d99f8cf55b34e6eadd4e7f59061e36d7875fec4a3bc0bc15
https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-c004679546311e65d99f8cf55b34e6eadd4e7f59061e36d7875fec4a3bc0bc15
https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-c004679546311e65d99f8cf55b34e6eadd4e7f59061e36d7875fec4a3bc0bc15
https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-c004679546311e65d99f8cf55b34e6eadd4e7f59061e36d7875fec4a3bc0bc15
https://github.com/googleapis/google-api-python-client/pull/2829/files#diff-c004679546311e65d99f8cf55b34e6eadd4e7f59061e36d7875fec4a3bc0bc15
Please reload this pagehttps://github.com/googleapis/google-api-python-client/pull/2829/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.