Skip to content

Restore ServerBuilder.WithMiddleware and WithRoute#5369

Merged
reyortiz3 merged 2 commits into
mainfrom
fix/restore-server-builder-extension-methods
May 22, 2026
Merged

Restore ServerBuilder.WithMiddleware and WithRoute#5369
reyortiz3 merged 2 commits into
mainfrom
fix/restore-server-builder-extension-methods

Conversation

@reyortiz3
Copy link
Copy Markdown
Contributor

@reyortiz3 reyortiz3 commented May 22, 2026

Summary

  • Why: Remove unreachable functions identified by deadcode analysis #5355 ("Remove unreachable functions identified by deadcode analysis") dropped ServerBuilder.WithMiddleware and ServerBuilder.WithRoute. These are the only public surface available to ApplyServerExtensions consumers — 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 wires ApplyServerExtensions fails to compile (b.WithMiddleware undefined, b.WithRoute undefined).
  • What:
    • Restore both methods on ServerBuilder with doc comments stating that they are part of the public extension contract and should not be deleted on deadcode analysis alone.
    • Add TestServerBuilderExtensionPoints so 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

  • Bug fix

Test plan

  • Unit tests (task test for ./pkg/api/... — all green, including the new TestServerBuilderExtensionPoints)
  • Linting (task lint-fix — 0 issues)
  • Manual testing: verified a downstream consumer that calls b.WithMiddleware(...) and b.WithRoute(...) via ApplyServerExtensions compiles cleanly with this patch.

🤖 Generated with Claude Code

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>
@reyortiz3 reyortiz3 requested review from JAORMX and amirejaz as code owners May 22, 2026 15:08
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label May 22, 2026
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>
@github-actions github-actions Bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels May 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.73%. Comparing base (b9ec592) to head (6858685).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reyortiz3 reyortiz3 merged commit 686eb1b into main May 22, 2026
47 checks passed
@reyortiz3 reyortiz3 deleted the fix/restore-server-builder-extension-methods branch May 22, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants