Skip to content

Handle Google MCP auth transport failures - #1230

Open
Yeagerist0 wants to merge 1 commit into
OWASP:mainfrom
Yeagerist0:fix/mcp-auth-network-errors
Open

Yeagerist0 wants to merge 1 commit into
OWASP:mainfrom
Yeagerist0:fix/mcp-auth-network-errors

Conversation

@Yeagerist0

@Yeagerist0 Yeagerist0 commented Nov 15, 2026 •

Copy link
Copy Markdown

Summary

The MCP Google device-flow and refresh requests currently let requests.ConnectionError and requests.Timeout escape. As a result, login prints a traceback and status can crash when Google's token endpoint is unreachable.

Route all three Google POST operations through a small helper that converts transport failures to AuthError. Login now reports a concise failure; status returns its existing logged_in: false result with a useful error. The exception text is deliberately omitted so request details and credentials cannot leak into CLI output.

This is separate from #1163/#1165, which address REST calls made by MCP tools, and from #1229, which addresses file-backed token storage on Windows.

Verification

  • Four new regression tests cover device endpoint connection failure, polling timeout, refresh connection failure in status, and refresh timeout. PYTHONPATH=/tmp/opencre-app-deps:$PWD python -m unittest application.tests.mcp_auth_test application.tests.mcp_auth_network_test -v passed: 17 tests total (dependencies installed only in a temporary path).
  • uvx black --check on both changed files passed.
  • python -m compileall -q and git diff --check passed.
  • The full application test suite remains unrun. No live Google request was made.

LLM Usage Considerations

Codex helped investigate, implement, test, and describe this change. The behavior was checked with the stated tests. Independent review by the human contributor is pending; no claim of human validation is made.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary by CodeRabbit

  • Bug Fixes
    • Sign-in and token refresh now handle connection failures more clearly, showing a general message instead of exposing underlying network errors.
    • Timeouts during device authorization and token refresh are reported distinctly, including the applicable timeout duration.

Walkthrough

Google authentication POST requests now use a shared helper that handles timeouts and other request failures. Tests cover device authorization, device-code polling, and token refresh failures.

Changes

Google authentication request handling

Layer / File(s) Summary
Request handling and network failure coverage
application/mcp/auth.py, application/tests/mcp_auth_network_test.py
Refresh, device authorization, and device-code polling use a shared helper for timed Google POST requests. The helper converts timeouts and other request failures into operation-specific AuthError messages. Tests check login and refresh behavior for connection failures and timeouts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 2ecc7

Google login and token refresh now report network timeouts and connection failures as concise authentication errors instead of raw exceptions. The change is small and localized, with regression tests for the failure paths. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "Handle Google MCP auth transport failures" matches the main change: the Google device-flow and token-refresh POST calls now convert requests.ConnectionError and requests.Timeout into AuthEr…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the problem (ConnectionError and Timeout escaping from Google device-flow and refresh POSTs), the fix (a helper that converts these to AuthError), the affected commands (login a…
Full details: Title check

Explanation

The title "Handle Google MCP auth transport failures" matches the main change: the Google device-flow and token-refresh POST calls now convert requests.ConnectionError and requests.Timeout into AuthError via a helper in application/mcp/auth.py. It is specific and concise, and a teammate scanning history would understand the primary change.

Full details: Description check

Explanation

The description states the problem (ConnectionError and Timeout escaping from Google device-flow and refresh POSTs), the fix (a helper that converts these to AuthError), the affected commands (login and status), and the regression tests run. It is directly related to the changeset, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: OWASP/OpenCRE
  • Branch: main
  • File: .coderabbit.yml
  • Commit: 6bc7a30
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 263029eb-53c5-4387-8e2b-bb979e9066bf
Commits

Reviewing files that changed from the base of the PR and between 6bc7a30 and 2ecc758.

Files selected for processing: 2

  • application/mcp/auth.py
  • application/tests/mcp_auth_network_test.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant