Refactor shared pagination/map-extraction paths and isolate server rate-limit helpers#6799
Merged
Merged
Conversation
Closed
4 tasks
Copilot
AI
changed the title
[WIP] Refactor identified opportunities in semantic function clustering analysis
Refactor shared pagination/map-extraction paths and isolate server rate-limit helpers
May 31, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors repeated helper logic without changing behavior, improving locality for server rate-limit handling and shared proxy map-string extraction while documenting pagination invariants.
Changes:
- Moved server-side rate-limit result parsing helpers into
internal/server/rate_limit.go. - Added
strutil.GetStringFromMapwith unit coverage and adopted it in selected proxy argument extraction paths. - Added cross-reference comments between production and test pagination helpers.
Show a summary per file
| File | Description |
|---|---|
internal/server/rate_limit.go |
New home for unexported rate-limit parsing/detection helpers. |
internal/server/circuit_breaker.go |
Removes moved helper implementations and unused imports. |
internal/strutil/map.go |
Adds shared map string extraction helper. |
internal/strutil/map_test.go |
Covers helper behavior for present, missing, non-string, and nil map cases. |
internal/proxy/proxy.go |
Uses shared helper for REST owner/repo/number string extraction. |
internal/proxy/graphql.go |
Uses shared helper for GraphQL owner/repo variable extraction. |
internal/proxy/collaborator_permission.go |
Uses shared helper for collaborator permission arguments. |
internal/mcp/pagination.go |
Documents alignment with test pagination loop-protection invariants. |
internal/testutil/mcptest/validator.go |
Documents alignment with production pagination loop-protection invariants. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 9/9 changed files
- Comments generated: 0
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.
This change addresses the semantic-clustering refactor findings by reducing repeated helper logic and improving locality of concern. It keeps behavior stable while making shared invariants and extraction paths explicit.
Rate-limit logic isolation (
internal/server)circuit_breaker.gointorate_limit.go:isRateLimitToolResultisRateLimitTextparseRateLimitResetFromTextextractRateLimitErrorTextShared string extraction for
map[string]interface{}(internal/strutil,internal/proxy)strutil.GetStringFromMap(m, key)and unit tests.Pagination invariant coupling made explicit
internal/mcp/pagination.go:paginateAllinternal/testutil/mcptest/validator.go:paginate