René's URL Explorer Experiment


Title: google.api_core.iam.Policy.__getitem__ does not correctly save empty bindings · Issue #154 · googleapis/python-api-core · GitHub

Open Graph Title: google.api_core.iam.Policy.__getitem__ does not correctly save empty bindings · Issue #154 · googleapis/python-api-core

X Title: google.api_core.iam.Policy.__getitem__ does not correctly save empty bindings · Issue #154 · googleapis/python-api-core

Description: We recently tried to upgrade a tool from 1.15.0 to 1.26.1 and found it breaks some code that handles IAM policies. The commit that introduces the bug was released in 1.16.0: fd47fda#diff-7cc73ea72342c139ff54060be9ff25b2f792f9225e0cc0f501...

Open Graph Description: We recently tried to upgrade a tool from 1.15.0 to 1.26.1 and found it breaks some code that handles IAM policies. The commit that introduces the bug was released in 1.16.0: fd47fda#diff-7cc73ea723...

X Description: We recently tried to upgrade a tool from 1.15.0 to 1.26.1 and found it breaks some code that handles IAM policies. The commit that introduces the bug was released in 1.16.0: fd47fda#diff-7cc73ea723...

Opengraph URL: https://github.com/googleapis/python-api-core/issues/154

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"google.api_core.iam.Policy.__getitem__ does not correctly save empty bindings","articleBody":"We recently tried to upgrade a tool from 1.15.0 to 1.26.1 and found it breaks some code that handles IAM policies.  The commit that introduces the bug was released in 1.16.0: https://github.com/googleapis/python-api-core/commit/fd47fda5e3f5eca63522c8d81cffa22bc2a29ab6#diff-7cc73ea72342c139ff54060be9ff25b2f792f9225e0cc0f501dca9dbed9c4741 - \r\n\r\nThe new `__getitem__` implementation returns a new empty `set()` for roles not in the current policy.  But it doesn't save that set in the bindings.  So if the user manipulates it, the policy isn't actually updated.  That breaks code written like this:\r\n```python\r\npolicy = resource.get_iam_policy()\r\npolicy['roles/storage.objectAdmin'].add(principal)\r\nbucket.set_iam_policy(policy)\r\n```\r\nThis worked fine on v1.15.0 because of the use of `defaultdict`.  But now, this adds the principal to a set that's not used by the policy.\r\n\r\nSomething like the following (untested) patch should do the trick:\r\n```diff\r\ndiff --git a/google/api_core/iam.py b/google/api_core/iam.py\r\nindex f130936..d650336 100644\r\n--- a/google/api_core/iam.py\r\n+++ b/google/api_core/iam.py\r\n@@ -136,7 +136,9 @@ class Policy(collections_abc.MutableMapping):\r\n         for b in self._bindings:\r\n             if b[\"role\"] == key:\r\n                 return b[\"members\"]\r\n-        return set()\r\n+\r\n+        self[key] = set()\r\n+        return self[key]\r\n\r\n     def __setitem__(self, key, value):\r\n         self.__check_version__()\r\n\r\n```","author":{"url":"https://github.com/rvandegrift","@type":"Person","name":"rvandegrift"},"datePublished":"2021-03-18T19:55:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/154/python-api-core/issues/154"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4868b49c-cc32-e39a-0bcc-3fa5568fff9d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA704:26A272:2AC001:3D93FD:6A4E2ADE
html-safe-nonce055952c78c2440282c3228f1cf3aa65663dc959cec7b1786bd7a1a00ab7282ea
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzA0OjI2QTI3MjoyQUMwMDE6M0Q5M0ZEOjZBNEUyQURFIiwidmlzaXRvcl9pZCI6IjMwNjQxMzg2MzQwNzAyMDcxOTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac6614b738542dfe7db2c0c6faa9e52ea9d52f4264aeb0d2fe2cb1e3391594d3c1
hovercard-subject-tagissue:835197463
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-api-core/154/issue_layout
twitter:imagehttps://opengraph.githubassets.com/96c80cac8580c8afdb72f6ad71eb757a1a47dc745d64a3f21bf5e9b940b450e4/googleapis/python-api-core/issues/154
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/96c80cac8580c8afdb72f6ad71eb757a1a47dc745d64a3f21bf5e9b940b450e4/googleapis/python-api-core/issues/154
og:image:altWe recently tried to upgrade a tool from 1.15.0 to 1.26.1 and found it breaks some code that handles IAM policies. The commit that introduces the bug was released in 1.16.0: fd47fda#diff-7cc73ea723...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamervandegrift
hostnamegithub.com
expected-hostnamegithub.com
None030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released9dd20d38f8ae3c4cb6b597807431db300d0bd2a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/python-api-core/issues/154#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-api-core%2Fissues%2F154
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%2Fissues%2F154
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-api-core
Reloadhttps://github.com/googleapis/python-api-core/issues/154
Reloadhttps://github.com/googleapis/python-api-core/issues/154
Reloadhttps://github.com/googleapis/python-api-core/issues/154
Please reload this pagehttps://github.com/googleapis/python-api-core/issues/154
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
#155https://github.com/googleapis/python-api-core/pull/155
google.api_core.iam.Policy.__getitem__ does not correctly save empty bindingshttps://github.com/googleapis/python-api-core/issues/154#top
#155https://github.com/googleapis/python-api-core/pull/155
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.https://github.com/googleapis/python-api-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-api-core/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
https://github.com/rvandegrift
rvandegrifthttps://github.com/rvandegrift
on Mar 18, 2021https://github.com/googleapis/python-api-core/issues/154#issue-835197463
fd47fda#diff-7cc73ea72342c139ff54060be9ff25b2f792f9225e0cc0f501dca9dbed9c4741https://github.com/googleapis/python-api-core/commit/fd47fda5e3f5eca63522c8d81cffa22bc2a29ab6#diff-7cc73ea72342c139ff54060be9ff25b2f792f9225e0cc0f501dca9dbed9c4741
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.https://github.com/googleapis/python-api-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-api-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.