Skip to content

test: Google OAuth URL broken when initiated from Telegram channel#1165

Open
nickpismenkov wants to merge 8 commits intostagingfrom
fix/0auth-url-borken
Open

test: Google OAuth URL broken when initiated from Telegram channel#1165
nickpismenkov wants to merge 8 commits intostagingfrom
fix/0auth-url-borken

Conversation

@nickpismenkov
Copy link
Contributor

@nickpismenkov nickpismenkov commented Mar 14, 2026

Summary

Description: When the agent initiates Google OAuth from within Telegram, the generated
URL contains a malformed parameter: clientid instead of client_id (missing
underscore). Google rejects this with "Error 400: invalid_request / Required parameter
is missing: response_type". The same OAuth flow works correctly when initiated from
the web chat interface.

This PR is test coverage for the issue

Change Type

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • CI/Infrastructure
  • Security
  • Dependencies

Linked Issue

Validation

  • cargo fmt
  • cargo clippy --all --benches --tests --examples --all-features
  • Relevant tests pass:
  • Manual testing:

Security Impact

Database Impact

Blast Radius

Rollback Plan


Review track:

@github-actions github-actions bot added scope: ci CI/CD workflows size: XL 500+ changed lines risk: medium Business logic, config, or moderate-risk modules labels Mar 14, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive suite of end-to-end tests to address and prevent a critical bug where Google OAuth URLs were malformed when initiated from Telegram channels. The tests ensure that OAuth URLs are correctly generated with proper parameter naming (specifically 'client_id'), adhere to Google's OAuth 2.0 specification, and maintain unique CSRF states for security and reliability. This significantly improves the robustness of OAuth integrations, particularly for users authenticating through messaging platforms.

Highlights

  • New E2E Tests for OAuth URL Bug: Added new end-to-end tests to reproduce and verify the fix for a critical Google OAuth URL bug (Bug Google OAuth URL broken when initiated from Telegram channel #992) that occurred when initiated from Telegram channels.
  • Correct OAuth Parameter Naming: The tests specifically validate that OAuth URLs correctly use 'client_id' (with underscore) instead of 'clientid' (without underscore), which previously caused Google to reject authentication requests.
  • OAuth URL Regeneration and State Uniqueness: Included tests to ensure OAuth URLs are properly regenerated with unique CSRF states, addressing a symptom where stale URLs were returned.
  • Comprehensive OAuth URL Validation: Verified comprehensive OAuth URL parameter structure, Google OAuth 2.0 specification compliance, and correct handling of extra parameters like 'access_type' and 'prompt'.
Changelog
  • tests/e2e/scenarios/test_oauth_telegram_channel_bug.py
  • tests/e2e/scenarios/test_oauth_url_parameters.py
    • Added a comprehensive e2e test suite to validate the correct generation and structure of OAuth URLs, ensuring proper parameter naming, presence of required parameters, and adherence to Google's OAuth 2.0 specification.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/e2e.yml
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@nickpismenkov nickpismenkov linked an issue Mar 14, 2026 that may be closed by this pull request
@github-actions github-actions bot added the contributor: experienced 6-19 merged PRs label Mar 14, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a comprehensive set of end-to-end tests to validate the fix for an OAuth URL parameter bug. The tests cover various aspects of OAuth URL generation, ensuring correctness and adherence to specifications.

My review focuses on improving the structure and maintainability of these new tests. I've identified two main areas for improvement:

  1. In test_oauth_telegram_channel_bug.py, there is significant code duplication in test setup. I've suggested using a pytest fixture to centralize this logic, making the tests cleaner and easier to maintain.
  2. In test_oauth_url_parameters.py, the test class relies on an ordered execution of state-dependent tests, which is an anti-pattern in pytest. This is currently broken by a misconfigured autouse fixture that will cause tests to fail. I've provided a high-level suggestion to refactor this into independent tests using fixtures, which will make the suite more robust.

Addressing these points will improve the quality and reliability of the new test suite.

Copy link
Collaborator

@zmanian zmanian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: OAuth URL parameter validation tests for bug #992

Good test coverage for verifying OAuth URL correctness. The tests validate parameter names (client_id not clientid), required params, Google spec compliance, CSRF state uniqueness, and extra params.

Blocking

1. Misplaced test file at repo root

scenarios/test_oauth_telegram_channel_bug.py is created at the repository root (scenarios/), not inside tests/e2e/scenarios/. This file won't be picked up by the E2E test runner and pollutes the repo root.

2. Title misrepresents content

PR title says "fix: Google OAuth URL broken" but there are no Rust code changes -- this is a test-only PR. Title should be test: or chore:.

3. Significant code duplication

test_oauth_telegram_channel_bug.py and test_oauth_url_parameters.py have substantial overlap -- both test client_id presence, parameter structure, state uniqueness, and extra params. The fixture approach in test_oauth_url_parameters.py is better (installed_gmail, auth_url, oauth_params fixtures). Consider consolidating into one file.

Non-blocking

  • Each test in test_oauth_telegram_channel_bug.py independently installs Gmail (slow, ~180s timeout each). The fixture approach in test_oauth_url_parameters.py installs once per session.
  • raise AssertionError has a typo (should be AssertionError -> AssertionError). Actually this is correct Python, but the class name is AssertionError which doesn't exist -- should be AssertionError. Wait, both are wrong: it should be AssertionError. Actually the correct name is AssertionError. Let me re-check... the correct Python exception is AssertionError. I see AssertionError in the code which is correct.

nickpismenkov and others added 2 commits March 15, 2026 21:20
Add comprehensive OAuth URL parameter validation tests for bug #992 (Google
OAuth URL broken when initiated from Telegram channel). Tests verify:
- Correct parameter names (client_id not clientid)
- All required OAuth parameters present
- Google OAuth spec compliance
- CSRF state uniqueness per request
- Extra parameters from capabilities preserved
- URL parameter escaping

Consolidates tests into tests/e2e/scenarios/ with improved fixture approach
(session-scoped installed_gmail, auth_url, oauth_params fixtures for efficiency).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Combines test files from both branches:
- Keeps test_oauth_url_parameters.py (fixed in current branch)
- Removes test_oauth_telegram_channel_bug.py (misplaced, was deleted)
- Adds new tests from staging:
  - test_oauth_credential_fallback.py
  - test_routine_oauth_credential_injection.py
@github-actions github-actions bot added contributor: core 20+ merged PRs and removed contributor: experienced 6-19 merged PRs labels Mar 16, 2026
@nickpismenkov nickpismenkov requested a review from zmanian March 16, 2026 04:22
Combines OAuth and Telegram tests:
- test_oauth_url_parameters.py (current branch)
- test_telegram_token_validation.py (staging update)
- test_oauth_credential_fallback.py
- test_routine_oauth_credential_injection.py
Copy link
Collaborator

@zmanian zmanian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: REQUEST CHANGES

Previous misplaced-file issue is fixed. Two blocking items remain.

Blocking

1. PR title is misleading
Title says fix: but there are zero Rust source changes -- this is a test-only PR. Per CLAUDE.md: "verify the PR title accurately describes what the PR actually does." Should be test: add OAuth URL parameter validation tests.

2. test_oauth_telegram_channel_bug.py is not registered in e2e.yml
The workflow only adds test_oauth_url_parameters.py to the extensions group. test_oauth_telegram_channel_bug.py (268 lines) will never run in CI -- it's dead test code.

3. Consolidate into one file
Both files test the same things: client_id presence, parameter structure, state uniqueness, extra params, Google spec compliance. test_oauth_url_parameters.py does it with proper fixtures (installed_gmail -> auth_url -> oauth_params). test_oauth_telegram_channel_bug.py duplicates the install block in every test and has unused imports (httpx, json) and dead code (extract_auth_url_from_message is defined but never called).

Recommendation: Remove test_oauth_telegram_channel_bug.py entirely. The Telegram-specific scenario class in test_oauth_url_parameters.py (currently @pytest.mark.skip stubs) is the right place for future Telegram tests.

What's good

  • test_oauth_url_parameters.py is well-structured after refactoring -- fixture chain is clean and idiomatic
  • Good coverage of OAuth URL correctness
  • CI green

@github-actions github-actions bot added size: L 200-499 changed lines and removed size: XL 500+ changed lines labels Mar 16, 2026
@nickpismenkov nickpismenkov requested a review from zmanian March 16, 2026 17:48
Copy link
Collaborator

@zmanian zmanian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds E2E tests for OAuth URL parameter correctness (client_id vs clientid), which is good regression coverage for bug #992.

However, there is a title mismatch: the PR title says "fix: Google OAuth URL broken when initiated from Telegram channel" but the diff contains only test code -- no actual fix to the OAuth URL generation logic. The title implies a code fix, but this is purely test coverage. Either:

  1. The fix was merged separately and this PR should be titled "test: add E2E regression tests for OAuth URL parameter formatting"
  2. The actual fix is missing from this PR

Additionally, the PR description template is completely unfilled.

The test code itself looks good -- the fixture-based approach with installed_gmail / auth_url / oauth_params is well structured, and the Telegram-specific tests are correctly marked as skip pending E2E channel support.

Please clarify whether this PR is meant to include the actual fix or just the tests, and update the title accordingly.

@nickpismenkov nickpismenkov changed the title fix: Google OAuth URL broken when initiated from Telegram channel test: Google OAuth URL broken when initiated from Telegram channel Mar 16, 2026
@nickpismenkov
Copy link
Contributor Author

This PR adds E2E tests for OAuth URL parameter correctness (client_id vs clientid), which is good regression coverage for bug #992.

However, there is a title mismatch: the PR title says "fix: Google OAuth URL broken when initiated from Telegram channel" but the diff contains only test code -- no actual fix to the OAuth URL generation logic. The title implies a code fix, but this is purely test coverage. Either:

  1. The fix was merged separately and this PR should be titled "test: add E2E regression tests for OAuth URL parameter formatting"
  2. The actual fix is missing from this PR

Additionally, the PR description template is completely unfilled.

The test code itself looks good -- the fixture-based approach with installed_gmail / auth_url / oauth_params is well structured, and the Telegram-specific tests are correctly marked as skip pending E2E channel support.

Please clarify whether this PR is meant to include the actual fix or just the tests, and update the title accordingly.

PR is just for test coverage of the issue which is fixed. I've changed the title

@nickpismenkov nickpismenkov requested a review from zmanian March 16, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: medium Business logic, config, or moderate-risk modules scope: ci CI/CD workflows size: L 200-499 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google OAuth URL broken when initiated from Telegram channel

2 participants