Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
Problem:
After #7550 made explicit auth headers authoritative,
McpTool._get_headers()can still emit the literal headerAuthorization: Bearer Nonewhen an OAuth2 credential object exists without an access token. That invalid auth header then overrides a validheader_providervalue during invocation, while discovery correctly keeps the provider header.Copybara imported the earlier #7550 patch as
f82aa222before its final revision added this guard and regression coverage.Solution:
Only construct an OAuth2
Authorizationheader whenaccess_tokenis non-empty. Otherwise, return no OAuth auth header and allow the existing provider header to remain effective.The change is deliberately limited to the OAuth2 guard and one regression test at the MCP session-creation boundary.
Testing Plan
Unit Tests:
The new test fails on current main with:
After the fix:
Also verified:
The full repository test suite was not run.
Manual End-to-End (E2E) Tests:
Not run. The regression test asserts the final headers passed to
create_session().Checklist
Additional context
The later credential-manager fix in
7fca46f1rejects an unredeemed authorization-code credential, but it does not cover an empty-token credential without an auth code or one returned by a custom auth provider. Guarding header construction remains necessary at this boundary.