Restore ServerBuilder.WithMiddleware and WithRoute#5369
Merged
Conversation
These two methods are the only public API available to ApplyServerExtensions hooks (the enterprise overlay uses them to inject session-auth middleware and mount an /enterprise sub-router). #5355 dropped them as unreachable because the only callers live behind //go:build enterprise, which upstream CI does not exercise. Add a unit test that exercises both methods so future deadcode passes see them as live, and add doc comments explaining the extension-point contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reframe the doc comments and test rationale around the public extension
point itself ("ApplyServerExtensions consumers", "downstream repositories")
rather than the internal identity of any particular consumer. The behavior
of the methods is unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ChrisJBurns
approved these changes
May 22, 2026
JAORMX
approved these changes
May 22, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5369 +/- ##
==========================================
+ Coverage 68.70% 68.73% +0.02%
==========================================
Files 625 625
Lines 63422 63428 +6
==========================================
+ Hits 43575 43595 +20
+ Misses 16604 16583 -21
- Partials 3243 3250 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
ServerBuilder.WithMiddlewareandServerBuilder.WithRoute. These are the only public surface available toApplyServerExtensionsconsumers — the extension point this codebase exposes for downstream builds to inject middleware and mount additional routes. The deadcode tool reported them as unreachable because their callers live in repositories whose source it doesn't have access to. After v0.28.2, any build that wiresApplyServerExtensionsfails to compile (b.WithMiddleware undefined,b.WithRoute undefined).ServerBuilderwith doc comments stating that they are part of the public extension contract and should not be deleted on deadcode analysis alone.TestServerBuilderExtensionPointsso future deadcode passes see both methods as live within this repository.The other five
With*methods deleted in #5355 (WithContainerRuntime,WithClientManager,WithWorkloadManager,WithGroupManager,WithSkillManager) remain removed — no known consumer needs them.Type of change
Test plan
task testfor./pkg/api/...— all green, including the newTestServerBuilderExtensionPoints)task lint-fix— 0 issues)b.WithMiddleware(...)andb.WithRoute(...)viaApplyServerExtensionscompiles cleanly with this patch.🤖 Generated with Claude Code