Commit 7ce47d7
refactor(mcp): inline _request_scope and tighten _extract_response_data
Two more simplifications in utils.py the reviewer/PM flagged:
1. _request_scope was a no-op wrapper around logfire.span that added
nothing — same name, same attributes, one call deep. Inlined at all
5 call sites (call_get/put/post/patch/delete). The helper is gone.
2. _extract_response_data used `except Exception` to swallow any JSON
decode failure. That's defensive code for upstream gateway HTML
error pages (Fly/Cloudflare 5xx); FastAPI itself always emits JSON.
Replaced with a content-type check: if the response doesn't claim
`application/json`, return None; otherwise let any decode error
surface. Matches CLAUDE.md's fail-fast guidance.
Tests updated: MockResponse fixtures now include a
`headers = {"content-type": "application/json"}` attribute so they
pass the new gate.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>1 parent 85ce163 commit 7ce47d7
3 files changed
Lines changed: 40 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
117 | 121 | | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | | - | |
| 125 | + | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
| |||
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | 176 | | |
196 | 177 | | |
197 | 178 | | |
| |||
231 | 212 | | |
232 | 213 | | |
233 | 214 | | |
234 | | - | |
235 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
236 | 218 | | |
237 | 219 | | |
238 | 220 | | |
239 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
240 | 224 | | |
241 | 225 | | |
242 | 226 | | |
| |||
328 | 312 | | |
329 | 313 | | |
330 | 314 | | |
331 | | - | |
332 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
333 | 318 | | |
334 | 319 | | |
335 | 320 | | |
336 | | - | |
| 321 | + | |
| 322 | + | |
337 | 323 | | |
338 | 324 | | |
339 | 325 | | |
| |||
430 | 416 | | |
431 | 417 | | |
432 | 418 | | |
433 | | - | |
434 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
435 | 422 | | |
436 | 423 | | |
437 | 424 | | |
438 | | - | |
| 425 | + | |
| 426 | + | |
439 | 427 | | |
440 | 428 | | |
441 | 429 | | |
| |||
538 | 526 | | |
539 | 527 | | |
540 | 528 | | |
541 | | - | |
542 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
543 | 532 | | |
544 | 533 | | |
545 | 534 | | |
546 | | - | |
| 535 | + | |
| 536 | + | |
547 | 537 | | |
548 | 538 | | |
549 | 539 | | |
| |||
665 | 655 | | |
666 | 656 | | |
667 | 657 | | |
668 | | - | |
669 | | - | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
670 | 661 | | |
671 | 662 | | |
672 | 663 | | |
673 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
674 | 667 | | |
675 | 668 | | |
676 | 669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
0 commit comments