Repository navigation
Conversation
…no expiry calculate_token_expiry declares int|str but calls int(), so a server emitting a fractional expires_in as a string raises ValueError during token setup, and a float input is truncated instead of kept. Parse with float() so both work. is_token_valid tested token_expiry_time for truthiness, so an expiry of 0.0 was read as 'no expiry' and the token was presented forever. Compare against None explicitly. Tests cover None, int, numeric string, fractional string and float inputs, plus the zero-expiry predicate.
Contributor
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and this PR doesn't link an open issue yet.
You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
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.
Scope correction (this PR stays closed)
I opened this as two defects with user-visible impact and I was wrong about the impact. Checking the path end to end after the fact:
OAuthToken.expires_inisint | None, and pydantic rejects both"3599.5"and3599.5with aValidationErrorbeforecalculate_token_expiryis ever called.float()there therefore does not repair any reachable flow; it only makes a defensive helper match its own annotation and docstring.token_expiry_timeis written only fromcalculate_token_expiry(orNone), so a literal0.0is not reachable through SDK code. The falsy-zero change is hardening for state a caller supplies, not a bug fix.The expiry boundary is the real defect in this area and a maintainer already has it: #3761.
So this is a two-line hardening patch on defensive paths, not a bug fix, and the repository's contribution policy is clear that a change still has to justify the contract it adds. Leaving it closed unless a maintainer wants the hardening. The evidence for the claim above, measured on current
main:What the diff does, described accurately
src/mcp/shared/auth_utils.py:calculate_token_expirydeclaresint | str | Noneand documents string handling, but callsint(expires_in), which raises on a fractional string and truncates a float. Usingfloat()makes the helper agree with its own annotation. No reachable caller benefits today.src/mcp/client/auth/oauth2.py:is_token_valid()readsnot self.token_expiry_time, which conflatesNone("no expiry declared") with any falsy value, including0.0. Comparing againstNoneexplicitly states the intended meaning. No SDK path currently produces0.0.tests/shared/test_auth_utils.pyandtests/client/test_auth.pycarry the matching tests for both, including theNone, integer, numeric-string, fractional-string and float inputs the annotation already claimed to support.Verification