fix: dedupe builder-vite project annotation imports#34374
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughGenerateProjectAnnotations now ensures import alias uniqueness by tracking used variable names and appending incrementing suffixes (_2, _3, ...) for collisions. A Vitest suite was added to verify deterministic alias generation and correct HMR module references. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
code/builders/builder-vite/src/codegen-project-annotations.test.ts (1)
42-46: The self-referential assertion pattern is valid but consider adding a sanity check.The assertion constructs the expected array using
importVariables[0], which correctly tests the relative suffix pattern (_2,_3) without hardcoding the base name. However, if the base name were somehow empty or malformed, the test could still pass spuriously.Consider adding a minimal sanity assertion on the base identifier format:
💡 Optional: Add sanity check for base identifier
const importVariables = [...result.matchAll(/import \* as (\w+) from/g)].map( (match) => match[1] ); + // Sanity check: base identifier should match expected format (preview_<hash>) + expect(importVariables[0]).toMatch(/^preview_\d+$/); expect(importVariables).toEqual([ importVariables[0], `${importVariables[0]}_2`, `${importVariables[0]}_3`, ]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code/builders/builder-vite/src/codegen-project-annotations.test.ts` around lines 42 - 46, The test currently builds expected values from importVariables[0], which can mask a malformed base; add a quick sanity assertion before the existing expect to ensure importVariables[0] is a valid, non-empty JS identifier (for example assert it matches a regex like /^[A-Za-z_$][A-Za-z0-9_$]*$/ or at least is non-empty) so the subsequent relative-suffix assertions (the expect that compares to `${importVariables[0]}_2`, `${importVariables[0]}_3`) cannot pass spuriously if the base name is empty or invalid; update the test in codegen-project-annotations.test.ts to include this check prior to the existing equality assertion involving importVariables.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@code/builders/builder-vite/src/codegen-project-annotations.test.ts`:
- Around line 42-46: The test currently builds expected values from
importVariables[0], which can mask a malformed base; add a quick sanity
assertion before the existing expect to ensure importVariables[0] is a valid,
non-empty JS identifier (for example assert it matches a regex like
/^[A-Za-z_$][A-Za-z0-9_$]*$/ or at least is non-empty) so the subsequent
relative-suffix assertions (the expect that compares to
`${importVariables[0]}_2`, `${importVariables[0]}_3`) cannot pass spuriously if
the base name is empty or invalid; update the test in
codegen-project-annotations.test.ts to include this check prior to the existing
equality assertion involving importVariables.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 21c76c57-cf4c-498b-abb5-9338e47e4678
📒 Files selected for processing (2)
code/builders/builder-vite/src/codegen-project-annotations.test.tscode/builders/builder-vite/src/codegen-project-annotations.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- code/builders/builder-vite/src/codegen-project-annotations.ts
|
Hi @raashish1601 , Due to a recent high volume of unreviewed AI-generated PRs, we are requesting verification and proof that the implemented fix actually works. Please provide a simple GIF/Video or image of how the bugfix works, optimally with before-and-after comparisons. Thank you for your understanding! |
|
Hi @raashish1601, We requested verification that this PR works as intended, but haven't received a response in over two weeks. We're closing this PR for now. If you'd like to continue working on this, feel free to reopen the PR with the requested verification (a GIF/video or screenshot showing before-and-after behavior). Thank you for your contribution! |
Summary
Testing
Summary by CodeRabbit
Bug Fixes
Tests