Commit 9aef516
authored
fix(mcp-proxy): isolate MCP reload panics (#2959)
* fix(mcp-proxy): skip invalid OpenAPI parameters
Why this change was needed:
OpenAPI input can contain nil parameter refs or schema refs with neither a value nor a resolved reference. The converter previously dereferenced those shapes while building MCP tool schemas.
What changed:
- Added a schema-ref presence check before marshaling OpenAPI schemas
- Skipped nil, empty, or schema-less parameters instead of building partial parameter schemas
- Reused the same guard for JSON request bodies with empty schema refs
- Added a regression test covering invalid parameter entries
Problem solved:
Bad parameter metadata no longer panics the OpenAPI-to-MCP converter.
* fix(mcp-proxy): isolate MCP reload panics per server
Why this change was needed:
A panic while applying one MCP server reload could interrupt the whole reload round. A panic in concurrent prefetch could also be recovered without being recorded on that server result, making later stats misleading.
What changed:
- Added per-server panic recovery around applyServerChanges processing
- Counted apply panics as load errors while continuing to later servers
- Recorded prefetch panics on the matching serverLoadResult
- Added regression tests for prefetch panic attribution and apply-stage isolation
Problem solved:
Bad data from one MCP server no longer prevents later servers in the same reload round from being applied, and recovered prefetch panics are counted as server load errors.
* fix(mcp-proxy): guard nil MCP reload apply results
Why this change was needed:
A nil server result from reload prefetch could still panic during the apply phase before per-server panic isolation ran, stopping later servers from being applied.
What changed:
- Count nil apply results as reload errors before accessing the server name
- Make apply panic recovery logging safe when the server is nil
- Add a regression test that verifies a nil result does not block a later valid server
Problem solved:
MCP reload now preserves per-server isolation for nil-server apply results, so one malformed result cannot abort the rest of the reload.
* fix(mcp-proxy): report reload panic stack traces
Why this change was needed:
Reload panic isolation logged only the panic value, which made per-server prefetch and apply failures harder to diagnose after recovery.
What changed:
- Added a shared reload panic reporting helper with stack traces
- Reported reload panic phase and MCP server name to Sentry context
- Added a regression test for stack and Sentry report metadata
Problem solved:
Recovered MCP reload panics now retain enough diagnostic context for operations without losing per-server isolation.
* fix(mcp-proxy): preserve tools on failed reload updates
Why this change was needed:
Reload updates could prune existing tools before the new OpenAPI spec update had succeeded, and update failures were counted as skipped reloads.
What changed:
- Apply the new MCP server spec before pruning stale tools
- Return update errors separately from no-op updates
- Count update failures as reload errors instead of skips
- Add regressions for failed update state preservation and error accounting
Problem solved:
A failed MCP reload update no longer leaves the existing server with prematurely removed tools, and reload stats now report update failures accurately.
* docs(mcp-proxy): clarify OpenAPI ref handling in converter
Why this change was needed:
The converter keeps accepting Ref-only schema refs, which can look like it allows dangling refs to reach MCP tool schemas.
What changed:
- Document that LoadFromData resolves valid refs and rejects dangling refs before reload conversion
Problem solved:
Future review of the converter can distinguish production reload behavior from defensive compatibility in the helper.1 parent 87ed78e commit 9aef516
5 files changed
Lines changed: 534 additions & 92 deletions
File tree
- src/mcp-proxy/pkg
- infra/proxy
- mcp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
| |||
212 | 217 | | |
213 | 218 | | |
214 | 219 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
239 | 232 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
246 | 246 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | 247 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
264 | 260 | | |
265 | 261 | | |
266 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
267 | 275 | | |
268 | 276 | | |
269 | 277 | | |
| |||
299 | 307 | | |
300 | 308 | | |
301 | 309 | | |
302 | | - | |
| 310 | + | |
303 | 311 | | |
304 | 312 | | |
305 | 313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
287 | 329 | | |
288 | 330 | | |
289 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
110 | 119 | | |
111 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
112 | 135 | | |
113 | 136 | | |
114 | 137 | | |
| |||
0 commit comments