René's URL Explorer Experiment


Title: `project` kwarg ignored when `from_service_account_json` is used · Issue #108 · googleapis/python-cloud-core · GitHub

Open Graph Title: `project` kwarg ignored when `from_service_account_json` is used · Issue #108 · googleapis/python-cloud-core

X Title: `project` kwarg ignored when `from_service_account_json` is used · Issue #108 · googleapis/python-cloud-core

Description: Copied from an internal bug 191836777 with some examples tweaked to have generic names. @tseaver Could you take a look? When creating a bq client with explicit project name, for example ('my-project') and explicit gcp json key ('other-pr...

Open Graph Description: Copied from an internal bug 191836777 with some examples tweaked to have generic names. @tseaver Could you take a look? When creating a bq client with explicit project name, for example ('my-projec...

X Description: Copied from an internal bug 191836777 with some examples tweaked to have generic names. @tseaver Could you take a look? When creating a bq client with explicit project name, for example ('my-pr...

Opengraph URL: https://github.com/googleapis/python-cloud-core/issues/108

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`project` kwarg ignored when `from_service_account_json` is used","articleBody":"Copied from an internal bug 191836777 with some examples tweaked to have generic names.\r\n\r\n@tseaver Could you take a look?\r\n\r\n---\r\nWhen creating a bq client with explicit project name, for example ('my-project') and explicit gcp json key ('other-project.json'). The connection context is set to the project specified in the json (other-project) and not the explicit one given as an argument (my-project).\r\n\r\nCreated a service account in project \"pynix-cloud\"\r\n\r\nCreate a test script as below:\r\n\r\n```py\r\nfrom google.cloud import bigquery\r\nproject1 = \"pynix-cloud\"\r\nproject2 = \"fileshare-project\"\r\n\r\nprint('Creating client1 for project: %s' %project1)\r\nclient1 = bigquery.Client.from_service_account_json('owner-sa.json', project=project1)\r\nprint(\"Getting the project context for client1: %s\" %client1.project)\r\nprint(\" \")\r\nprint(\"Creating client2 for project: %s\" %project2)\r\nclient2 = bigquery.Client.from_service_account_json('owner-sa.json', project=project2)\r\nprint(\"Getting the project context for client2: %s\" %client2.project)\r\n```\r\n\r\nRunning this scripts outputs as below:\r\n\r\n```\r\nCreating client1 for project: pynix-cloud\r\nGetting the project context for client1: pynix-cloud\r\n \r\nCreating client2 for project: fileshare-project\r\nGetting the project context for client2: pynix-cloud\r\n```\r\n\r\nHowever, the intended behaviour should be that the context for client2 should be the project \"fileshare-project\" as that is the project been passed explicitly as argument.\r\n\r\nDebugging on the issue and going over the code I have following observations:\r\n\r\nThe bigquery client class has a call to super class \"ClientWithProject\" as per [1]. The class \"ClientWithProject\" is imported in the same code and is part of the core package [2].\r\n\r\nI read thru the code for class \"ClientWithProject\" and stopped at this line [3]. I suspected there to be missing something so I tired to play around the same. What I did was I modified the line in [3]\r\n\r\n\r\nfrom :\r\n```\r\nreturn cls.from_service_account_info(credentials_info)\r\n```\r\nto:\r\n```py\r\nreturn cls.from_service_account_info(credentials_info,**kwargs)\r\n```\r\nmind the keywords been passed as arguments. Post this I again ran my test script and I got the expected results, ie the context was from the project been passed as argument:\r\n```\r\nCreating client1 for project: pynix-cloud\r\nGetting the project context for client1: pynix-cloud\r\n \r\nCreating client2 for project: fileshare-project\r\nGetting the project context for client2: fileshare-project\r\n```\r\nAs this is something seen broken in v1.7 for core component. Looking at the release note for core 1.7 [4] there was a change where in we added 'Client.from_service_account_info' factory [5]. this function is indeed the one been called in [3]. If we refer to the code from 1.4.1 this was not implemented there [6]. Also when the customer downgraded the core component to 1.4 it started working as expected.\r\n\r\nSo my best take is that may be this is a bug and not the intended behaviour for v1.7. We might have missed passing the keywords as args so when at line [7] the keyword dict is empty and we tend to fetch the project from the service account json file itself.\r\n\r\nKindly let me know if this observation is correct and if we can do the required changes to get this working again in case the issue reported is not an indented behaviour in v1.7.\r\n\r\n[1] https://github.com/googleapis/python-bigquery/blob/18bb443c7acd0a75dcb57d9aebe38b2d734ff8c7/google/cloud/bigquery/client.py#L199\r\n\r\n[2] from google.cloud.client import ClientWithProject\r\n\r\n[3] https://github.com/googleapis/python-cloud-core/blob/1d3e273292e0c3eae2b150c9a05e610eb4ade78d/google/cloud/client.py#L109\r\n\r\n[4] https://github.com/googleapis/python-cloud-core/tree/master/google/cloud\r\n\r\n[5] https://github.com/googleapis/python-cloud-core/pull/54\r\n\r\n[6] https://github.com/googleapis/python-cloud-core/blob/release-v1.4.1/google/cloud/client.py\r\n\r\n[7] https://github.com/googleapis/python-cloud-core/blob/1d3e273292e0c3eae2b150c9a05e610eb4ade78d/google/cloud/client.py#L78\r\n\r\nGitHub repository: https://github.com/googleapis/python-cloud-core","author":{"url":"https://github.com/busunkim96","@type":"Person","name":"busunkim96"},"datePublished":"2021-06-23T16:49:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/108/python-cloud-core/issues/108"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:cb1873b3-2764-f4e7-0583-77fc53fda69e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBAE4:2C03D:8246093:B6560CC:6A5006C5
html-safe-nonced6a45dcc25bb1f5079886b013c59fff913780b23e8279983fee995f56d4b9972
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQUU0OjJDMDNEOjgyNDYwOTM6QjY1NjBDQzo2QTUwMDZDNSIsInZpc2l0b3JfaWQiOiIxODg2NjU2OTU1OTgxNzYwMTk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmace8baacc13dd1df8269c812d0ae6a59ccbc7bb467b66649d4184d5b633467ef85
hovercard-subject-tagissue:928457153
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-cloud-core/108/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3c74c3aba9f9d0a9e634b211cf7cccebb9d9ee8e201b3401754bb7db5608dddd/googleapis/python-cloud-core/issues/108
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3c74c3aba9f9d0a9e634b211cf7cccebb9d9ee8e201b3401754bb7db5608dddd/googleapis/python-cloud-core/issues/108
og:image:altCopied from an internal bug 191836777 with some examples tweaked to have generic names. @tseaver Could you take a look? When creating a bq client with explicit project name, for example ('my-projec...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebusunkim96
hostnamegithub.com
expected-hostnamegithub.com
None56eec25a3430492dd6ec2a480eb33256a0da5192d5714b0db4f5ab5f33203d94
turbo-cache-controlno-preview
go-importgithub.com/googleapis/python-cloud-core git https://github.com/googleapis/python-cloud-core.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id226992462
octolytics-dimension-repository_nwogoogleapis/python-cloud-core
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id226992462
octolytics-dimension-repository_network_root_nwogoogleapis/python-cloud-core
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release93a615b89b7dcbdb6b678f4772931ecc28ada82a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/python-cloud-core/issues/108#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-cloud-core%2Fissues%2F108
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/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/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/enterprise/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-cloud-core%2Fissues%2F108
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%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=googleapis%2Fpython-cloud-core
Reloadhttps://github.com/googleapis/python-cloud-core/issues/108
Reloadhttps://github.com/googleapis/python-cloud-core/issues/108
Reloadhttps://github.com/googleapis/python-cloud-core/issues/108
Please reload this pagehttps://github.com/googleapis/python-cloud-core/issues/108
googleapis https://github.com/googleapis
python-cloud-corehttps://github.com/googleapis/python-cloud-core
Notifications https://github.com/login?return_to=%2Fgoogleapis%2Fpython-cloud-core
Fork 19 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-cloud-core
Star 34 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-cloud-core
Code https://github.com/googleapis/python-cloud-core
Issues 0 https://github.com/googleapis/python-cloud-core/issues
Pull requests 0 https://github.com/googleapis/python-cloud-core/pulls
Actions https://github.com/googleapis/python-cloud-core/actions
Projects https://github.com/googleapis/python-cloud-core/projects
Security and quality 0 https://github.com/googleapis/python-cloud-core/security
Insights https://github.com/googleapis/python-cloud-core/pulse
Code https://github.com/googleapis/python-cloud-core
Issues https://github.com/googleapis/python-cloud-core/issues
Pull requests https://github.com/googleapis/python-cloud-core/pulls
Actions https://github.com/googleapis/python-cloud-core/actions
Projects https://github.com/googleapis/python-cloud-core/projects
Security and quality https://github.com/googleapis/python-cloud-core/security
Insights https://github.com/googleapis/python-cloud-core/pulse
#109https://github.com/googleapis/python-cloud-core/pull/109
project kwarg ignored when from_service_account_json is usedhttps://github.com/googleapis/python-cloud-core/issues/108#top
#109https://github.com/googleapis/python-cloud-core/pull/109
https://github.com/tseaver
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.https://github.com/googleapis/python-cloud-core/issues?q=state%3Aopen%20label%3A%22priority%3A%20p1%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/python-cloud-core/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
https://github.com/busunkim96
busunkim96https://github.com/busunkim96
on Jun 23, 2021https://github.com/googleapis/python-cloud-core/issues/108#issue-928457153
@tseaverhttps://github.com/tseaver
https://github.com/googleapis/python-bigquery/blob/18bb443c7acd0a75dcb57d9aebe38b2d734ff8c7/google/cloud/bigquery/client.py#L199https://github.com/googleapis/python-bigquery/blob/18bb443c7acd0a75dcb57d9aebe38b2d734ff8c7/google/cloud/bigquery/client.py#L199
python-cloud-core/google/cloud/client.pyhttps://github.com/googleapis/python-cloud-core/blob/1d3e273292e0c3eae2b150c9a05e610eb4ade78d/google/cloud/client.py#L109
1d3e273https://github.com/googleapis/python-cloud-core/commit/1d3e273292e0c3eae2b150c9a05e610eb4ade78d
https://github.com/googleapis/python-cloud-core/tree/master/google/cloudhttps://github.com/googleapis/python-cloud-core/tree/master/google/cloud
#54https://github.com/googleapis/python-cloud-core/pull/54
https://github.com/googleapis/python-cloud-core/blob/release-v1.4.1/google/cloud/client.pyhttps://github.com/googleapis/python-cloud-core/blob/release-v1.4.1/google/cloud/client.py
python-cloud-core/google/cloud/client.pyhttps://github.com/googleapis/python-cloud-core/blob/1d3e273292e0c3eae2b150c9a05e610eb4ade78d/google/cloud/client.py#L78
1d3e273https://github.com/googleapis/python-cloud-core/commit/1d3e273292e0c3eae2b150c9a05e610eb4ade78d
https://github.com/googleapis/python-cloud-corehttps://github.com/googleapis/python-cloud-core
tseaverhttps://github.com/tseaver
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.https://github.com/googleapis/python-cloud-core/issues?q=state%3Aopen%20label%3A%22priority%3A%20p1%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/python-cloud-core/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
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.