fix(tool_google_workspace): make check_connection actually probe the API - #1700
Conversation
connection_ok was derived only from local checks (client constructed, token scopes claimed) for gmail/drive/docs/sheets, since check_connection called _check_connection_impl() without a probe. calendar was the only service with a live probe wired, so a disabled Google API on the caller's project was invisible everywhere else — connection_ok: true while every real call 403'd. - Wire a live probe for gmail (users().getProfile), drive (about().get), and docs/sheets (a made-up-id get(), swallowing the expected 404 since neither API has a list/about endpoint to probe cheaply). - _check_connection_impl no longer defaults to True when no probe runs; it reports 'unknown' instead, and fixes a bug where the scope-coverage check could silently coerce that sentinel back to a bool. - execute() now attaches the structured Google reason code (e.g. accessNotConfigured vs forbidden vs rateLimitExceeded) to raised errors, surfaced as errorReason. Closes rocketride-org#1694
🤖 Internal: Discord sync markerAuto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete. |
📝 WalkthroughWalkthroughGoogle Workspace connection diagnostics now perform service-specific API probes, report unknown status when no probe runs, validate OAuth scope coverage, and surface structured API error reasons across Docs, Drive, Gmail, and Sheets. ChangesGoogle Workspace diagnostics
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant check_connection
participant _check_connection_impl
participant GoogleWorkspaceAPI
participant token_scope_report
participant diagnostics
check_connection->>_check_connection_impl: provide service-specific probe
_check_connection_impl->>GoogleWorkspaceAPI: execute live API probe
GoogleWorkspaceAPI-->>_check_connection_impl: success, 404, or structured error
_check_connection_impl->>token_scope_report: validate required OAuth scopes
token_scope_report-->>_check_connection_impl: coverage and missing scopes
_check_connection_impl-->>diagnostics: connection_ok, checked, and errorReason
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 `@nodes/src/nodes/tool_google_workspace/gmail/IInstance.py`:
- Line 150: Update the Gmail connection probe in the relevant instance method to
call execute with both the Gmail service descriptor and the users.getProfile
request, preserving the existing userId='me' request and _check_connection_impl
flow.
🪄 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: ASSERTIVE
Plan: Pro Plus
Run ID: 738a1f45-287d-4890-83e0-6440320bf84b
📒 Files selected for processing (14)
nodes/src/nodes/tool_google_workspace/IInstance.pynodes/src/nodes/tool_google_workspace/docs/IInstance.pynodes/src/nodes/tool_google_workspace/docs/README.mdnodes/src/nodes/tool_google_workspace/drive/IInstance.pynodes/src/nodes/tool_google_workspace/drive/README.mdnodes/src/nodes/tool_google_workspace/gmail/IInstance.pynodes/src/nodes/tool_google_workspace/gmail/README.mdnodes/src/nodes/tool_google_workspace/google_client.pynodes/src/nodes/tool_google_workspace/sheets/IInstance.pynodes/src/nodes/tool_google_workspace/sheets/README.mdnodes/test/tool_google_workspace/docs/test_docs.pynodes/test/tool_google_workspace/drive/test_drive.pynodes/test/tool_google_workspace/gmail/test_gmail.pynodes/test/tool_google_workspace/sheets/test_sheets.py
Summary
check_connectionfor gmail/drive/docs/sheets derivedconnection_okentirelyfrom local checks (client object constructed, token's claimed scopes look
right) — it never called Google.
calendarwas the only service with a liveprobe wired. That's why a disabled Google API on the caller's project was
invisible:
connection_ok: truewhile every real call 403'd withaccessNotConfigured.users().getProfile), drive (about().get),and docs/sheets (
get()against a made-up resource id, swallowing theexpected 404 — neither API has a list/about endpoint to probe cheaply).
_check_connection_implno longer defaultsconnection_oktoTruewhenno probe runs; it now reports
'unknown'. Also fixes a latent bug where thescope-coverage check (
connection_ok and covered) could silently coercethat sentinel back to a bool.
execute()now attaches the structured Google reason code (e.g.accessNotConfiguredvsforbiddenvsrateLimitExceeded) to raisederrors, surfaced as
errorReasonin the diagnostic output.Closes #1694
Test plan
pytest nodes/test/tool_google_workspace/— 353 passed, 20 skipped(skipped tests require live Gmail OAuth creds, unrelated to this change)
ruff check/ruff format --checkcleanlocally, then called
check_connectionwith a syntactically-valid butfake OAuth token (httplib2 debug logging on). Confirmed a real HTTPS
round-trip to
gmail.googleapis.comand a genuine401from Google,with
connection_okcorrectly flipping tofalse. Re-ran the identicalscript against the pre-fix code (via a temporary
git stashof justthese two files) to confirm it silently returned
connection_ok: truewith zero network traffic — the exact bug in the issue.
Summary by CodeRabbit
New Features
Documentation
Tests