René's URL Explorer Experiment


Title: BrokenPipeError when using Attached Service Account on GCE Instance · Issue #2553 · googleapis/google-api-python-client · GitHub

Open Graph Title: BrokenPipeError when using Attached Service Account on GCE Instance · Issue #2553 · googleapis/google-api-python-client

X Title: BrokenPipeError when using Attached Service Account on GCE Instance · Issue #2553 · googleapis/google-api-python-client

Description: Environment details OS type and version: Google Compute Engine (GCE) with Container-Optimized OS Python version: Python 3.7.16 pip version: pip 21.3.1 google-api-python-client== 1.12.8 google-auth==1.35.0 google-auth-httplib2==0.2.0 Step...

Open Graph Description: Environment details OS type and version: Google Compute Engine (GCE) with Container-Optimized OS Python version: Python 3.7.16 pip version: pip 21.3.1 google-api-python-client== 1.12.8 google-auth=...

X Description: Environment details OS type and version: Google Compute Engine (GCE) with Container-Optimized OS Python version: Python 3.7.16 pip version: pip 21.3.1 google-api-python-client== 1.12.8 google-auth=...

Opengraph URL: https://github.com/googleapis/google-api-python-client/issues/2553

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BrokenPipeError when using Attached Service Account on GCE Instance","articleBody":"#### Environment details\n\n  - OS type and version: Google Compute Engine (GCE) with Container-Optimized OS  \n  - Python version: `Python 3.7.16`  \n  - pip version: `pip 21.3.1`  \n  - `google-api-python-client`== 1.12.8\n  - `google-auth`==1.35.0\n  - `google-auth-httplib2`==0.2.0\n\n#### Steps to reproduce\n\n  1. Deploy a Python application on a GCE instance with an attached service account.  \n  2. Use `google.auth.default()` for authentication.  \n  3. Let the service run for a few hours to allow the token to expire.  \n  4. Perform a Google Drive API call during token refresh (e.g., listing files or creating a folder).  \n\n#### Code example\n\n```python\ngdrive_credentials: Credentials = (\n    Credentials.from_service_account_info(\n        gcp_credentials_dict,\n        scopes=SCOPES,\n    )\n    if gcp_credentials_dict\n    else google.auth.default(scopes=SCOPES)[0]\n)\n\ndef create_services(credentials, scopes):\n    drive_service = build(\n        \"drive\", \"v3\", credentials=credentials\n    )\n    docs_service = build(\n        \"docs\", \"v1\", credentials=credentials\n    )\n\n    return credentials, drive_service, docs_service\n\ndef get_or_create_folder(self, drive_service, folder_name):\n    \"\"\"\n    Checks if a folder exists in the root directory and creates it if not.\n\n    :param drive_service: Authorized Drive API client.\n    :param folder_name: The name of the folder to check or create.\n    :return: The folder ID.\n    \"\"\"\n    # Search for the folder in the root directory\n    query = f\"name = '{folder_name}' and mimeType = 'application/vnd.google-apps.folder' and 'root' in parents and trashed = false\"\n    response = (\n        drive_service.files().list(q=query, fields=\"files(id, name)\").execute()\n    )\n    files = response.get(\"files\", [])\n\n    if files:\n        # Folder exists, return its ID\n        return files[0][\"id\"]\n    else:\n        # Folder doesn't exist, create it\n        folder_metadata = {\n            \"name\": folder_name,\n            \"mimeType\": \"application/vnd.google-apps.folder\",\n            \"parents\": [\"root\"],  # Place in the root directory\n        }\n        folder = (\n            drive_service.files()\n            .create(body=folder_metadata, fields=\"id\")\n            .execute()\n        )\n        return folder[\"id\"]\n```\n\n#### Stacktrace\n\n```bash\nBrokenPipeError: [Errno 32] Broken pipe\n  File \"/app/endpoints/webhooks.py\", line 292, in get_services_status\n    current_app.config.get(\"BUILD_ENVIRONMENT\"),\n  File \"/app/middleware/gdocsprinter.py\", line 43, in print_file_with_template\n    template_id, gdocs_drive_service, replace_template, build_environment\n  File \"/app/middleware/gdocsprinter.py\", line 111, in create_template_copy\n    drive_service, f\"{build_environment}-prints\"\n  File \"/app/middleware/gdocsprinter.py\", line 86, in get_or_create_folder\n    drive_service.files().list(q=query, fields=\"files(id, name)\").execute()\n  File \"googleapiclient/_helpers.py\", line 134, in positional_wrapper\n    return wrapped(*args, **kwargs)\n  File \"googleapiclient/http.py\", line 909, in execute\n    headers=self.headers,\n  File \"googleapiclient/http.py\", line 204, in _retry_request\n    raise exception\n  File \"googleapiclient/http.py\", line 177, in _retry_request\n    resp, content = http.request(uri, method, *args, **kwargs)\n  File \"google_auth_httplib2.py\", line 190, in request\n    self._request, method, uri, request_headers)\n  File \"/usr/local/lib/python3.7/site-packages/google/auth/credentials.py\", line 133, in before_request\n    self.refresh(request)\n  File \"/usr/local/lib/python3.7/site-packages/google/auth/compute_engine/credentials.py\", line 111, in refresh\n    self._retrieve_info(request)\n  File \"/usr/local/lib/python3.7/site-packages/google/auth/compute_engine/credentials.py\", line 88, in _retrieve_info\n    request, service_account=self._service_account_email\n  File \"/usr/local/lib/python3.7/site-packages/google/auth/compute_engine/_metadata.py\", line 234, in get_service_account_info\n    return get(request, path, params={\"recursive\": \"true\"})\n  File \"/usr/local/lib/python3.7/site-packages/google/auth/compute_engine/_metadata.py\", line 150, in get\n    response = request(url=url, method=\"GET\", headers=_METADATA_HEADERS)\n  File \"google_auth_httplib2.py\", line 117, in __call__\n    url, method=method, body=body, headers=headers, **kwargs)\n  File \"__init__.py\", line 1709, in request\n    conn, authority, uri, request_uri, method, body, headers, redirections, cachekey,\n  File \"__init__.py\", line 1424, in _request\n    (response, content) = self._conn_request(conn, request_uri, method, body, headers)\n  File \"__init__.py\", line 1347, in _conn_request\n    conn.request(method, request_uri, body, headers)\n  File \"http/client.py\", line 1281, in request\n    self._send_request(method, url, body, headers, encode_chunked)\n  File \"http/client.py\", line 1327, in _send_request\n    self.endheaders(body, encode_chunked=encode_chunked)\n  File \"http/client.py\", line 1276, in endheaders\n    self._send_output(message_body, encode_chunked=encode_chunked)\n  File \"http/client.py\", line 1036, in _send_output\n    self.send(msg)\n  File \"http/client.py\", line 997, in send\n    self.sock.sendall(data)\n```\n\n#### Brief summary\n\nAfter switching the authentication method for our application from service account keys to an attached service account on a Google Compute Engine (GCE) instance, we are encountering a BrokenPipeError during API calls to Google Drive.\n\nThe issue only occurs during token refresh after the application has been running for a couple of hours. Following the first failure, the service works again without intervention.\n\nThanks\n","author":{"url":"https://github.com/dantebarba","@type":"Person","name":"dantebarba"},"datePublished":"2025-01-21T16:25:37Z","url":"https://github.com/googleapis/google-api-python-client/issues/2553"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:634078e4-71b8-b09d-7cef-a3f122ae24b4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id90EE:32975D:20D9A:2CA58:6B0093A7
html-safe-noncebf3f593bc457a0485fb2746509d43bb567a8f2ba63c403f7fb2e7db3e16f2904
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MEVFOjMyOTc1RDoyMEQ5QToyQ0E1ODo2QjAwOTNBNyIsInZpc2l0b3JfaWQiOiI1MDYzNTA1NzMwNjc0Mzk4MTE5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac0b9e71c894f285d5c2d29af7108f009fd86cf32df9d686f8fc46fd8be305836c
hovercard-subject-tagissue:2802294434
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/google-api-python-client/2553/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ba779956a1276f040134d04427d65d6d4e837ce16590387b6a5c1fbcc3dbb53e/googleapis/google-api-python-client/issues/2553
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ba779956a1276f040134d04427d65d6d4e837ce16590387b6a5c1fbcc3dbb53e/googleapis/google-api-python-client/issues/2553
og:image:altEnvironment details OS type and version: Google Compute Engine (GCE) with Container-Optimized OS Python version: Python 3.7.16 pip version: pip 21.3.1 google-api-python-client== 1.12.8 google-auth=...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedantebarba
hostnamegithub.com
expected-hostnamegithub.com
Nonec710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08
turbo-cache-controlno-preview
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
disable-turbofalse
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
react-app-nameissues

Links:

Skip to contenthttps://github.com/googleapis/google-api-python-client/issues/2553#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-api-python-client%2Fissues%2F2553
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%2Fissues%2F2553
Sign uphttps://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%2Fgoogle-api-python-client
Reloadhttps://github.com/googleapis/google-api-python-client/issues/2553
Reloadhttps://github.com/googleapis/google-api-python-client/issues/2553
Reloadhttps://github.com/googleapis/google-api-python-client/issues/2553
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
https://github.com/googleapis/google-api-python-client
New issuehttps://github.com/login?return_to=https://github.com/googleapis/google-api-python-client/issues/2553
New issuehttps://github.com/login?return_to=https://github.com/googleapis/google-api-python-client/issues/2553
BrokenPipeError when using Attached Service Account on GCE Instancehttps://github.com/googleapis/google-api-python-client/issues/2553#top
priority: p3Desirable enhancement or fix. May not be included in next release.https://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22priority%3A%20p3%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
https://github.com/dantebarba
dantebarbahttps://github.com/dantebarba
on Jan 21, 2025https://github.com/googleapis/google-api-python-client/issues/2553#issue-2802294434
blunderbuss-gcfhttps://github.com/apps/blunderbuss-gcf
partheahttps://github.com/parthea
on Jan 21, 2025https://github.com/googleapis/google-api-python-client/issues/2553#event-16017125875
partheahttps://github.com/parthea
on Mar 18, 2025https://github.com/googleapis/google-api-python-client/issues/2553#event-16837107145
daniel-sanchehttps://github.com/daniel-sanche
priority: p3Desirable enhancement or fix. May not be included in next release.https://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22priority%3A%20p3%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
on Feb 27, 2026https://github.com/googleapis/google-api-python-client/issues/2553#event-23147599061
Sign up for freehttps://github.com/signup?return_to=https://github.com/googleapis/google-api-python-client/issues/2553
Sign in to commenthttps://github.com/login?return_to=https://github.com/googleapis/google-api-python-client/issues/2553
priority: p3Desirable enhancement or fix. May not be included in next release.https://github.com/googleapis/google-api-python-client/issues?q=state%3Aopen%20label%3A%22priority%3A%20p3%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/google-api-python-client/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.