fix(cloud): stop googleapiclient pulling in the system oauth2client (#10110)#10112
fix(cloud): stop googleapiclient pulling in the system oauth2client (#10110)#10112dpage wants to merge 2 commits into
Conversation
On packaged Linux installs the bundled venv is created with --system-site-packages (issue pgadmin-org#7173) so it can reach system packages such as dbus-python. That also exposes the deprecated system oauth2client and whatever pyOpenSSL ships alongside it. googleapiclient imports oauth2client optionally, and on Ubuntu 24.04 that drags in a pyOpenSSL too old for our bundled cryptography, aborting startup at blueprint registration with "AttributeError: module 'lib' has no attribute 'GEN_EMAIL'". pgAdmin only ever authenticates to Google via google-auth and google-auth-oauthlib, so park a None sentinel under sys.modules['oauth2client'] before importing googleapiclient in both the web module and the standalone pgacloud provider. The optional import then fails cleanly and googleapiclient falls back to google-auth. Closes pgadmin-org#10110
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughBoth Google provider entry points ( Changesoauth2client import guard and regression test
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/pgadmin/misc/cloud/google/tests/test_google_oauth2client_blocked.py`:
- Line 41: The scenarios class-level variable is defined as a mutable list
containing a dictionary, which can cause state leakage between tests and
violates Ruff RUF012. Convert the scenarios variable from a list to a tuple by
replacing the square brackets with parentheses, and ensure the inner dict is
also converted to a tuple representation (using tuples for key-value pairs or
another immutable structure) so that the entire scenarios container is immutable
and cannot be accidentally modified during test execution.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e90e0c79-f270-4322-aa40-b22cb4edc3ec
📒 Files selected for processing (3)
web/pgacloud/providers/google.pyweb/pgadmin/misc/cloud/google/__init__.pyweb/pgadmin/misc/cloud/google/tests/test_google_oauth2client_blocked.py
Summary
AttributeError: module 'lib' has no attribute 'GEN_EMAIL', thrown from the systempyOpenSSLwhilst registering the cloud blueprint.--system-site-packages(deliberately, for Python virtual environment as installed from Debian package lacksdbus-python#7173, so it can reach systemdbus-python), which also exposes the system's deprecatedoauth2clientand its companionpyOpenSSL.googleapiclient._authdoes an optionalimport oauth2client, picks it up from the system site-packages, and drags in that oldpyOpenSSL. The 9.16 bump of bundledcryptographyto 49.x is incompatible with it, so the import aborts and takes the whole app down.oauth2clientitself; it authenticates to Google viagoogle-auth/google-auth-oauthlib. The fix parks aNonesentinel undersys.modules['oauth2client']before importinggoogleapiclient, at both import sites (web/pgadmin/misc/cloud/google/__init__.pyand the standaloneweb/pgacloud/providers/google.py). The optional import then fails cleanly andgoogleapiclientfalls back togoogle-auth.--system-site-packagesflag is left intact, so the Python virtual environment as installed from Debian package lacksdbus-python#7173dbus-pythonbehaviour is unaffected.Test plan
test_google_oauth2client_blocked.py: importingcloud.googleinstalls the sentinel andgoogleapiclient._auth.HAS_OAUTH2CLIENTisFalse.runtests.py --pkg misc.cloud.google.tests— all 10 tests pass.pycodestyleclean on all changed files.Closes #10110
Summary by CodeRabbit
Bug Fixes
Tests
googleapiclientuses the non-legacy authentication path.