From bd09add399322135582e0c3e7155210cc7713a4c Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 20 Feb 2026 15:40:27 +0000 Subject: [PATCH] Update bug 5 with root cause, repro steps, and expected result Co-Authored-By: Claude Opus 4.6 --- ...bug-5-fix_collect_coverage_button_error.md | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.story_kit/bugs/bug-5-fix_collect_coverage_button_error.md b/.story_kit/bugs/bug-5-fix_collect_coverage_button_error.md index 713d9ac..1c27ca0 100644 --- a/.story_kit/bugs/bug-5-fix_collect_coverage_button_error.md +++ b/.story_kit/bugs/bug-5-fix_collect_coverage_button_error.md @@ -7,21 +7,26 @@ test_plan: pending ## Description -Pressing "Collect Coverage" in the workflow gates UI produces a large error. The feature expects a vitest `coverage-summary.json` but the project doesn't have coverage tooling configured. +Pressing "Collect Coverage" in the workflow gates UI produces a giant stack trace. The API endpoint `POST /workflow/coverage/collect` (`server/src/http/workflow.rs:430`) runs `pnpm run test:coverage` and when it fails, dumps the entire stderr into the error response (line 455). The frontend then renders this raw error. -## Expected Behavior +## Root Cause -Either the coverage collection works end-to-end, or the button is hidden/disabled when coverage tooling is not available. +`collect_coverage` in `workflow.rs` returns the full stderr from the failed `pnpm run test:coverage` command as a `bad_request` error. No truncation or sanitization. -## Steps to Reproduce +## How to Reproduce -1. Start the server -2. Open the frontend -3. Navigate to workflow gates -4. Press "Collect Coverage" -5. Large error is displayed +```bash +curl -s http://localhost:3001/api/workflow/coverage/collect \ + -H 'Content-Type: application/json' \ + -d '{"story_id":"any_story","threshold_percent":80}' | python3 -m json.tool +``` + +**Actual result:** A giant JSON error response containing the full stderr output from `pnpm run test:coverage` — hundreds of lines of stack traces. + +**Expected result:** A short, human-readable error message, e.g. `{"error": "Coverage not configured: no test:coverage script found in frontend/package.json"}` — or if the command exists but fails, a truncated summary (first 500 chars max). ## Acceptance Criteria -- [ ] "Collect Coverage" either works or fails gracefully with a clear message -- [ ] No giant error dump shown to the user +- [ ] `collect_coverage` API truncates/sanitizes error output before returning it (e.g. first 500 chars max) +- [ ] Frontend `GatePanel` renders coverage errors in a contained, non-overflowing way +- [ ] If `test:coverage` script doesn't exist in `package.json`, return a clear "coverage not configured" message instead of running the command