Conversation
Handle missing knip file issues safely by defaulting to an empty Set and iterating that normalized collection. Made-with: Cursor
Add a runKnip regression test that verifies missing issues.files does not throw and returns empty diagnostics. Made-with: Cursor
|
@acoBOYZ is attempting to deploy a commit to the Million Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d028dfd. Configure here.
| const diagnostics: Diagnostic[] = []; | ||
|
|
||
| for (const unusedFile of issues.files) { | ||
| for (const unusedFile of fileIssues) { |
There was a problem hiding this comment.
Missing runtime safety for other issue record types
Medium Severity
The fix adds a nullish-coalescing fallback for issues.files but doesn't apply the same guard to issues.exports, issues.types, or issues.duplicates. These are passed directly to collectIssueRecords, which calls Object.values(records) — this throws a TypeError if any of those fields are undefined. If Knip can return incomplete output missing files, it can equally omit these other fields, causing the same runtime crash this PR aims to prevent.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d028dfd. Configure here.


This fixes a runtime crash in the Knip integration when issues.files is missing..
Previously, we directly iterated over
issues.files, which could throw in edge cases when the field was unavailable at runtime.Now we normalize it first with a runtime-safe fallback:
Then we iterate over
fileIssuesinstead ofissues.files.This keeps existing behavior unchanged when file issues are present, while preventing failures when Knip returns incomplete or variant output.
Tests I added
issues.filesin `runKnipissues.filesvaluesNote
Low Risk
Low risk: small defensive change to avoid a runtime crash when Knip omits
issues.files, plus a focused regression test.Overview
Prevents
runKnipfrom crashing when Knip returnsissues.filesas missing/undefined by normalizing it to an emptySetbefore iteration.Adds a Vitest regression test that mocks Knip output without
issues.filesand assertsrunKnipresolves to an empty diagnostics array.Reviewed by Cursor Bugbot for commit d028dfd. Bugbot is set up for automated code reviews on this repo. Configure here.