Repository navigation
Return a test summary from run_tests - #18
Conversation
Co-authored-by: Claude <[email protected]>
| input: v.object({}), | ||
| async run({ log }) { | ||
| let output: string; | ||
| const reportPath = '/tmp/vitest.json'; |
There was a problem hiding this comment.
Bug: The code uses a hardcoded file path /tmp/vitest.json for test reports. This can cause race conditions or stale data reads if multiple reviews run concurrently on the same machine.
Severity: LOW
Suggested Fix
Use a unique filename for the temporary report file to avoid conflicts. This can be achieved by appending a unique identifier, such as a process ID (process.pid) or a timestamp, to the filename. For example, /tmp/vitest-${process.pid}.json. Ensure the temporary file is cleaned up after use.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: apps/pr-reviewer/src/agents/review.ts#L82
Potential issue: The code writes Vitest test coverage reports to a hardcoded path,
`/tmp/vitest.json`. While the current GitHub Actions environment likely isolates runs,
preventing this issue, it introduces a latent bug. If the execution environment changes
to a persistent one (e.g., a long-running server, a different CI system, or local
development), concurrent processes could overwrite this file, leading to a race
condition. Similarly, if a run fails to clean up the file, a subsequent run might read
stale data, leading to incorrect analysis. The code relies on environmental assumptions
for correctness.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9e04910. Configure here.
| } | ||
| let output: string; | ||
| try { | ||
| const report = JSON.parse(await readFile(reportPath, 'utf8')); |
There was a problem hiding this comment.
Stale test report can be reused
Low Severity
run_tests always reads /tmp/vitest.json after the process exits, including when this run never wrote that file. A leftover report from an earlier invocation is then returned as this run's counts and failure names.
Reviewed by Cursor Bugbot for commit 9e04910. Configure here.
| passed: report.numPassedTests, | ||
| failed: report.numFailedTests, | ||
| failures, | ||
| }); |
There was a problem hiding this comment.
Suite failures look like success
Medium Severity
The summary keeps only numFailedTests and assertion results whose status is failed, and it is returned even when the process exited non-zero. A file that failed to load therefore shows failed as 0 with an empty failures list, so the review treats the suite as passing.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 9e04910. Configure here.
|
Verdict: Approve with minor follow-ups — the refactor to structured JSON test output works (tests ran: 36 passed, 0 failed), but there are real robustness gaps worth addressing before merge. Correctness
Style
Tests
|
Co-authored-by: Claude <[email protected]>


run_tests now runs vitest with the JSON reporter and returns only the passed and failed counts plus the names of failing tests, so the full verbose log no longer enters the reviewer's prompt. The tests themselves, including the slow integration suite, are unchanged.
Created with Claude Code