ref(providers): Route requests through a central template registry#113
Draft
billyvg wants to merge 1 commit into
Draft
ref(providers): Route requests through a central template registry#113billyvg wants to merge 1 commit into
billyvg wants to merge 1 commit into
Conversation
Both providers built request paths from inline f-strings, so the only route information reaching an error was the fully-interpolated path — high cardinality and, for GitHub, impossible to reliably template after the fact (file paths, branches, and refs contain literal slashes). Introduce a shared Route/FormattedRoute helper and give each provider a central inline route registry (class GitHub / class GitLab). A Route carries its low-cardinality template alongside the concrete path, so the template travels with the request instead of being reverse-parsed. The request layer unwraps the concrete path for the wire and attaches the template to any raised error via a typed exc.scm_route seam on SCMCodedError, making the route reliably available at error time for Sentry tagging without emitting per-request paths. No behavior change: concrete request paths are byte-identical and the existing provider suites are unchanged. Adds Route unit tests and a per-provider seam test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Introduces a shared
Route/FormattedRoutehelper (src/scm/providers/routes.py) and converts both the GitHub and GitLab providers to a central, inline route-template registry (class GitHub/class GitLab, both usingRoute(...)).A
Routecouples a low-cardinality template (e.g./repos/{repo}/issues/{issue_id}) with the concrete path it formats. The request layer unwraps the concrete path for the wire and attaches the template to any raised error via a typedexc.scm_routeseam onSCMCodedError.Why
Both providers built paths from inline f-strings, so the only route information available at error time was the fully-interpolated path — high cardinality, and for GitHub impossible to reliably template after the fact (file paths, branches, and refs contain literal slashes, so reverse-parsing an interpolated path is ambiguous). Carrying the template with the request makes the route reliably recoverable, giving a clean low-cardinality dimension for Sentry issue tagging/grouping.
This is structural readiness:
scm_routeis made available at the error seam but is deliberately not emitted here — it is kept offextra_attributes. Wiring it into error context lands when this merges with the RPC error-envelope work.Behavior
request()(including/graphql). Out of scope:_web_base_urlbuilders and GraphQL query bodies.Tests
tests/unit/provider/test_routes.py—Routeformatting, template preservation, and the slash-containing-param reliability property.exc.scm_routecarries the template on a>= 400.mypyandruffclean.🤖 Generated with Claude Code