fix(publisher): treat GitHub device-flow slow_down as retriable#1290
Open
developer-ishan wants to merge 1 commit into
Open
fix(publisher): treat GitHub device-flow slow_down as retriable#1290developer-ishan wants to merge 1 commit into
slow_down as retriable#1290developer-ishan wants to merge 1 commit into
Conversation
GitHub's device-flow token endpoint returns slow_down when the client polls too frequently. Per RFC 8628 §3.5 this is a non-terminal signal: the client must increase its polling interval by 5 seconds and keep polling. The current pollForToken implementation only handles authorization_pending as retriable and bails on every other error, turning a routine rate-limit response into an unrecoverable "login failed: error polling for token: token request failed: slow_down". Treat slow_down the same as authorization_pending, bumping the interval per the RFC. Fixes modelcontextprotocol#1289
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.
Summary
slow_downresponse per RFC 8628 §3.5 — treat it as retriable and bump the polling interval by 5 seconds, instead of bailing with a fatal error.Fixes #1289.
Why
pollForTokenincmd/publisher/auth/github-at.goonly treatsauthorization_pendingas retriable. Every other response from GitHub's token endpoint — including the non-terminalslow_downsignal — falls through to:So users hitting GitHub's polling rate-limit get:
…and have to re-run
mcp-publisher login githubfrom scratch, which is especially painful becauseslow_downis more likely when the user takes more than a few seconds to enter and authorize the device code.Per RFC 8628 §3.5,
slow_downis defined as:Change
Treat
slow_downthe same asauthorization_pendingbut increaseintervalby 5 seconds before sleeping, matching the RFC exactly.A possible follow-up (not in this PR, to keep the diff minimal): seed the initial
intervalfromDeviceCodeResponse.Interval(already parsed but currently unused) instead of hardcoding5. Happy to do that here or as a separate PR if preferred.Test plan
go build ./cmd/publisher/...— cleango test ./cmd/publisher/auth/...— passesgofmt -dandgo vet ./cmd/publisher/auth/...— cleanmake check(lint + integration tests)I could not exercise
pollForTokenfrom a unit test without refactoringGitHubAccessTokenURLto be injectable, which felt out of scope for a bug-fix PR. Glad to add that refactor + a table-driven test forauthorization_pending/slow_down/ fatal errors in a follow-up if maintainers want it.