Repository navigation
Commit 4402667
fix: [#830] project_scan must not crash on missing binaries (32% error rate, 437 users)
Telemetry-2026-05-21 (2,503 machines, 14 days) shows `project_scan`
failing 32% of the time across 1,171 distinct users — the broadest
user-impact bug in the dataset. Every failure has the same fingerprint:
`Executable not found in $PATH: ?`.
Root cause (two-part)
1. `detectGit()` called `Bun.spawnSync(["git", ...])` three times with no
try/catch wrapper. Bun's `spawnSync` THROWS when the binary is missing
from PATH (not just when it exits non-zero). In any environment without
git installed — minimal Docker images, fresh Windows installs without
Git for Windows, some CI runners — the throw escaped detectGit, escaped
the Promise.all in execute(), and crashed the whole tool. The other
parts of the scan (dbt detection, env-var inspection, config files)
didn't depend on git but were lost too.
2. The PII masker (`telemetry/index.ts:1083-1084`) strips quoted strings
to `?`. Bun's error message `Executable not found in $PATH: "git"`
became `Executable not found in $PATH: ?` in telemetry — the binary
name was destroyed, making the bug look like a generic shell failure
for two months.
Fix
- New `safeSpawnSync` helper: catches the throw, returns `null` so callers
get a deterministic "command failed" instead of an exception. Used by
every `Bun.spawnSync` call in `detectGit()`.
- Every detection in `ProjectScanTool.execute()` now wraps with `.catch()`
that records the failure to a `degraded: string[]` list and continues
with a sentinel result. The tool no longer fails as a whole — it
always succeeds with partial results, and the LLM sees exactly what
was unavailable in both the output (a new "Degraded Detections"
section) and the metadata (`degraded` field).
- This implements the "make tool infallible with `degraded: [...]` field"
recommendation from the P0 triage doc.
Test
- New test "does not throw when git binary is missing from PATH" pins
the regression: sets PATH to an empty directory, calls `detectGit()`,
asserts it returns `{ isRepo: false }` without throwing. Pre-fix this
test would have thrown the masked error.
Validation
- `tsgo --noEmit`: pass.
- `bun test test/tool/project-scan.test.ts`: 78 pass / 0 fail (1 new test).
- Marker check: pass — no upstream-shared files touched.
Expected impact
- `project_scan` error rate drops from 32% to near-zero. Users without
git get a successful scan with `degraded: ["git"]` instead of an
opaque tool failure.
- Same defensive pattern protects against future Dispatcher/Config/Skill
failures that previously could have crashed the whole tool.
Closes #830
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 476d234 commit 4402667
2 files changed
Lines changed: 140 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
50 | 75 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 76 | + | |
| 77 | + | |
56 | 78 | | |
57 | 79 | | |
58 | 80 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
64 | 84 | | |
65 | 85 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
72 | 89 | | |
73 | 90 | | |
74 | 91 | | |
| |||
454 | 471 | | |
455 | 472 | | |
456 | 473 | | |
457 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
458 | 482 | | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
464 | 503 | | |
465 | 504 | | |
466 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
467 | 508 | | |
468 | 509 | | |
469 | | - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
470 | 514 | | |
471 | 515 | | |
472 | 516 | | |
473 | | - | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
474 | 521 | | |
475 | 522 | | |
476 | 523 | | |
477 | 524 | | |
478 | 525 | | |
479 | | - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
480 | 530 | | |
481 | 531 | | |
482 | 532 | | |
483 | 533 | | |
484 | 534 | | |
485 | | - | |
486 | | - | |
487 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
488 | 544 | | |
489 | 545 | | |
490 | | - | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
491 | 550 | | |
492 | 551 | | |
493 | 552 | | |
| |||
655 | 714 | | |
656 | 715 | | |
657 | 716 | | |
658 | | - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
659 | 723 | | |
660 | 724 | | |
661 | 725 | | |
| |||
702 | 766 | | |
703 | 767 | | |
704 | 768 | | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
705 | 782 | | |
706 | 783 | | |
707 | 784 | | |
708 | 785 | | |
709 | | - | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
710 | 789 | | |
711 | 790 | | |
712 | 791 | | |
| |||
729 | 808 | | |
730 | 809 | | |
731 | 810 | | |
| 811 | + | |
732 | 812 | | |
733 | 813 | | |
734 | 814 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
122 | 150 | | |
123 | 151 | | |
124 | 152 | | |
| |||
0 commit comments