René's URL Explorer Experiment


Title: feat: Add support for creating exceptions from an asynchronous response by ohmayr · Pull Request #688 · googleapis/python-api-core · GitHub

Open Graph Title: feat: Add support for creating exceptions from an asynchronous response by ohmayr · Pull Request #688 · googleapis/python-api-core

X Title: feat: Add support for creating exceptions from an asynchronous response by ohmayr · Pull Request #688 · googleapis/python-api-core

Description: This PR implements a _RestCall class to map GoogleAPICallError to an asynchronous rest callable that raises google.auth.exceptions.TransportError.This wrapping is done via a helper method rest_helpers_async.wrap_errors. A new parameter kind is introduced in wrap_method which can be one of grpc_asyncio (Default Value) or rest_asyncio to distinguish between the type of callables so that we can apply the appropriate wrapping logic. The property kind is exposed at the transport level here and will be configured when wrapping methods during the transport initialization here. As a follow up, a similar logic must be implemented for synchronous rest callables to avoid gRPC specific stack trace within a rest call. RE: Updated Workflow: I've removed the proposed _RestCall class after determining that it is not needed to wrap a rest callable and just adds unnecessary logic. The new proposed workflow is as follows: This PR still introduces a new parameter kind in wrap_method to determine the type of a callable i.e. grpc_asyncio or rest_asyncio. If kind=="rest_asyncio", we skip the call to grpc_helpers_async.wrap_errors which is gRPC specific. Essentially, this does the trick if we follow a similar pattern for error handling to what we're doing in a sync rest call. We have been lazily creating and raising a GoogleAPICallError from a requests.Response within our GAPICs using the from_http_response method here. Therefore, we don't need to add the error handling logic to the callable beforehand (we're currently doing both the things for a sync rest call and should skip wrapping the callable beforehand there too). This PR only handles the error handling logic for an async REST call. It also introduces a new helper i.e. format_http_response_error to create and raise a GoogleAPICallError for a more generic response since the existing from_http_response is specific to handling a requests response. Alternate approach for the introduced helper: The proposed implementation of format_http_response_error takes in payload as an argument so that we don't need to await for it within the call and keep this function synchronous. Alternatively, we can have an async version of from_http_response that can be used to create GoogleAPICallError for async rest calls. Follow Up: As a follow up, we should skip wrapping sync rest callable with grpc_helpers.wrap_errors (similar to what we're doing here) to avoid the unnecessary gRPC specific logic within a rest call stracktrace.

Open Graph Description: This PR implements a _RestCall class to map GoogleAPICallError to an asynchronous rest callable that raises google.auth.exceptions.TransportError.This wrapping is done via a helper method rest_help...

X Description: This PR implements a _RestCall class to map GoogleAPICallError to an asynchronous rest callable that raises google.auth.exceptions.TransportError.This wrapping is done via a helper method rest_help...

Opengraph URL: https://github.com/googleapis/python-api-core/pull/688

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:39756f08-0800-1f09-19b7-a693d0382e1c
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAD30:14248:E16958:144DF38:6A4E5036
html-safe-nonceb16a4c065c000135caa76b032583145f9f5b159d3bc536489a02b018e3f316f9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDMwOjE0MjQ4OkUxNjk1ODoxNDRERjM4OjZBNEU1MDM2IiwidmlzaXRvcl9pZCI6IjU2NjMzMjU2OTc2OTI1NTMyNzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaceefbd79e670cb109ca13ea78654aff2b2171dc1868747ba689d4697c91027338
hovercard-subject-tagpull_request:2032487857
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/python-api-core/pull/688/files
twitter:imagehttps://avatars.githubusercontent.com/u/28692176?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/28692176?s=400&v=4
og:image:altThis PR implements a _RestCall class to map GoogleAPICallError to an asynchronous rest callable that raises google.auth.exceptions.TransportError.This wrapping is done via a helper method rest_help...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/googleapis/python-api-core git https://github.com/googleapis/python-api-core.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id226992456
octolytics-dimension-repository_nwogoogleapis/python-api-core
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id226992456
octolytics-dimension-repository_network_root_nwogoogleapis/python-api-core
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
releasef344f1eab54fc7dfc02d0d018cda7e158c3db65c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/python-api-core/pull/688/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-api-core%2Fpull%2F688%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-api-core%2Fpull%2F688%2Ffiles
Sign up https://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%2Fpython-api-core
Reloadhttps://github.com/googleapis/python-api-core/pull/688/files
Reloadhttps://github.com/googleapis/python-api-core/pull/688/files
Reloadhttps://github.com/googleapis/python-api-core/pull/688/files
Please reload this pagehttps://github.com/googleapis/python-api-core/pull/688/files
googleapis https://github.com/googleapis
python-api-corehttps://github.com/googleapis/python-api-core
Notifications https://github.com/login?return_to=%2Fgoogleapis%2Fpython-api-core
Fork 97 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-api-core
Star 144 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-api-core
Code https://github.com/googleapis/python-api-core
Issues 0 https://github.com/googleapis/python-api-core/issues
Pull requests 0 https://github.com/googleapis/python-api-core/pulls
Actions https://github.com/googleapis/python-api-core/actions
Projects https://github.com/googleapis/python-api-core/projects
Security and quality 0 https://github.com/googleapis/python-api-core/security
Insights https://github.com/googleapis/python-api-core/pulse
Code https://github.com/googleapis/python-api-core
Issues https://github.com/googleapis/python-api-core/issues
Pull requests https://github.com/googleapis/python-api-core/pulls
Actions https://github.com/googleapis/python-api-core/actions
Projects https://github.com/googleapis/python-api-core/projects
Security and quality https://github.com/googleapis/python-api-core/security
Insights https://github.com/googleapis/python-api-core/pulse
ohmayrhttps://github.com/ohmayr
mainhttps://github.com/googleapis/python-api-core/tree/main
add-support-for-mapping-rest-callableshttps://github.com/googleapis/python-api-core/tree/add-support-for-mapping-rest-callables
Conversation 14 https://github.com/googleapis/python-api-core/pull/688
Commits 11 https://github.com/googleapis/python-api-core/pull/688/commits
Checks 0 https://github.com/googleapis/python-api-core/pull/688/checks
Files changed https://github.com/googleapis/python-api-core/pull/688/files
Please reload this pagehttps://github.com/googleapis/python-api-core/pull/688/files
feat: Add support for creating exceptions from an asynchronous response https://github.com/googleapis/python-api-core/pull/688/files#top
Show all changes 11 commits https://github.com/googleapis/python-api-core/pull/688/files
2fc2b35 feat: add suport for mapping exceptions to rest callables ohmayr Aug 22, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/2fc2b35f26057650b4bf3c5898ea5a187a3da633
573413a avoid wrapping errors for rest callable ohmayr Aug 23, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/573413ac69de1de4223c9fe589a36bda1f84f419
9c76b5f fix lint issues ohmayr Aug 23, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/9c76b5ff10243f8c3ad64a86469b76f351deafe8
2373149 add test coverage ohmayr Aug 23, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/2373149e1037f0ea7a4107d45ef88fc4004c4c55
dd7b5d1 address PR comments ohmayr Sep 9, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/dd7b5d1110946fa54f223487c5f4ff78a8fa6998
f7ebadd 🦉 Updates from OwlBot post-processor gcf-owl-bot[bot] Sep 9, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/f7ebadd0aa6a92b3021d1e24a893be9f42270de1
be83346 fix lint issues ohmayr Sep 9, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/be83346bf596ff3cd39e375c4940185c9f2deeec
b477772 Merge branch 'add-support-for-mapping-rest-callables' of github.com:g… ohmayr Sep 9, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/b4777729c0d4abc72707dd5c6901e785ac1211b7
cd13bdf Merge branch 'main' into add-support-for-mapping-rest-callables ohmayr Sep 10, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/cd13bdfb7bb505de8f1e08a6112029c995918899
324a2a0 fix for none type method ohmayr Sep 10, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/324a2a010162ec73031046d631b0fc99f14c253d
cabb338 Merge branch 'add-support-for-mapping-rest-callables' of github.com:g… ohmayr Sep 10, 2024 https://github.com/googleapis/python-api-core/pull/688/commits/cabb33865c5c5e79415350cc930cddf9606d8ded
Clear filters https://github.com/googleapis/python-api-core/pull/688/files
Please reload this pagehttps://github.com/googleapis/python-api-core/pull/688/files
Please reload this pagehttps://github.com/googleapis/python-api-core/pull/688/files
exceptions.py https://github.com/googleapis/python-api-core/pull/688/files#diff-9e3107d123dc6c10d09336071035de56d78969e69389d39486ccc9a1483f40e3
method_async.py https://github.com/googleapis/python-api-core/pull/688/files#diff-d4a2ac0a199127de486ffa3b4b6032e3d37faf961b1f80343ff4e2bb6efad912
test_method_async.py https://github.com/googleapis/python-api-core/pull/688/files#diff-0fe43af876ef09c7d7fb7aa997dcaa7080733f0dbd76a1cdc4bcce0e84c75a95
google/api_core/exceptions.pyhttps://github.com/googleapis/python-api-core/pull/688/files#diff-9e3107d123dc6c10d09336071035de56d78969e69389d39486ccc9a1483f40e3
View file https://github.com/googleapis/python-api-core/blob/cabb33865c5c5e79415350cc930cddf9606d8ded/google/api_core/exceptions.py
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/googleapis/python-api-core/pull/688/files
https://github.co/hiddenchars
https://github.com/googleapis/python-api-core/pull/688/{{ revealButtonHref }}
https://github.com/googleapis/python-api-core/pull/688/files#diff-9e3107d123dc6c10d09336071035de56d78969e69389d39486ccc9a1483f40e3
https://github.com/googleapis/python-api-core/pull/688/files#diff-9e3107d123dc6c10d09336071035de56d78969e69389d39486ccc9a1483f40e3
https://github.com/googleapis/python-api-core/pull/688/files#diff-9e3107d123dc6c10d09336071035de56d78969e69389d39486ccc9a1483f40e3
Please reload this pagehttps://github.com/googleapis/python-api-core/pull/688/files
https://github.com/googleapis/python-api-core/pull/688/files#diff-9e3107d123dc6c10d09336071035de56d78969e69389d39486ccc9a1483f40e3
https://github.com/googleapis/python-api-core/pull/688/files#diff-9e3107d123dc6c10d09336071035de56d78969e69389d39486ccc9a1483f40e3
https://github.com/googleapis/python-api-core/pull/688/files#diff-9e3107d123dc6c10d09336071035de56d78969e69389d39486ccc9a1483f40e3
google/api_core/gapic_v1/method_async.pyhttps://github.com/googleapis/python-api-core/pull/688/files#diff-d4a2ac0a199127de486ffa3b4b6032e3d37faf961b1f80343ff4e2bb6efad912
View file https://github.com/googleapis/python-api-core/blob/cabb33865c5c5e79415350cc930cddf9606d8ded/google/api_core/gapic_v1/method_async.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/googleapis/python-api-core/pull/688/{{ revealButtonHref }}
https://github.com/googleapis/python-api-core/pull/688/files#diff-d4a2ac0a199127de486ffa3b4b6032e3d37faf961b1f80343ff4e2bb6efad912
https://github.com/googleapis/python-api-core/pull/688/files#diff-d4a2ac0a199127de486ffa3b4b6032e3d37faf961b1f80343ff4e2bb6efad912
https://github.com/googleapis/python-api-core/pull/688/files#diff-d4a2ac0a199127de486ffa3b4b6032e3d37faf961b1f80343ff4e2bb6efad912
tests/asyncio/gapic/test_method_async.pyhttps://github.com/googleapis/python-api-core/pull/688/files#diff-0fe43af876ef09c7d7fb7aa997dcaa7080733f0dbd76a1cdc4bcce0e84c75a95
View file https://github.com/googleapis/python-api-core/blob/cabb33865c5c5e79415350cc930cddf9606d8ded/tests/asyncio/gapic/test_method_async.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/googleapis/python-api-core/pull/688/{{ revealButtonHref }}
https://github.com/googleapis/python-api-core/pull/688/files#diff-0fe43af876ef09c7d7fb7aa997dcaa7080733f0dbd76a1cdc4bcce0e84c75a95
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.