• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stacklok / toolhive / 20856154197
50%

Build:
DEFAULT BRANCH: main
Ran 09 Jan 2026 03:08PM UTC
Jobs 1
Files 427
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

09 Jan 2026 03:06PM UTC coverage: 50.048% (-0.02%) from 50.069%
20856154197

push

github

web-flow
Add Recovery Middleware to Prevent Server Crashes from Panics (#3219)

This PR implements dedicated panic recovery middleware to ensure all toolhive servers recover gracefully from panics instead of crashing. Previously, panic recovery was inconsistently handled within the telemetry middleware, which is optional and may not be enabled.

Closes #3107

Changes
New Recovery Package (pkg/recovery/)

Created RecoveryMiddleware that catches panics, logs them, and returns HTTP 500
Implements the types.Middleware interface for factory pattern integration
Includes unit tests for panic recovery scenarios
Proxy Runner Integration (pkg/runner/)

Registered recovery middleware factory in GetSupportedMiddlewareFactories()
Added recovery middleware to both PopulateMiddlewareConfigs() and WithMiddlewareFromFlags()
Positioned as the outermost wrapper to catch panics from all other middleware
thv API Server Integration (pkg/api/server.go)

Added recovery middleware as the first middleware in the chi router chain
vMCP Server Integration (pkg/vmcp/server/server.go)

Applied recovery middleware as the outermost wrapper in the MCP handler chain
Telemetry Middleware Cleanup (pkg/telemetry/middleware.go)

Removed redundant panic recovery code (outer handler recover, span.End recover, WriteHeader recover)
Recovery is now handled by the dedicated middleware
Testing
Added unit tests for recovery middleware covering:
Normal requests pass through correctly
Panics are recovered and return 500 Internal Server Error
Request context is preserved through the middleware

---------

Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>

13 of 46 new or added lines in 6 files covered. (28.26%)

29145 of 58234 relevant lines covered (50.05%)

58.11 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
3
0.0
0.0% pkg/api/server.go
7
0.0
0.0% pkg/runner/middleware.go
11
57.86
-1.02% pkg/runner/config_builder.go
12
42.86
pkg/recovery/recovery.go
Jobs
ID Job ID Ran Files Coverage
1 20856154197.1 09 Jan 2026 03:08PM UTC 427
50.05
GitHub Action Run
Source Files on build 20856154197
  • Tree
  • List 427
  • Changed 5
  • Source Changed 5
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #20856154197
  • deda935f on github
  • Prev Build on main (#20855252142)
  • Next Build on main (#20857988219)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc