fix(llms): avoid import(variableName) pattern#3733
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR makes small, localized changes in two LLMs runtime server files. In the plugin, the generated markdown is asserted non-null before being pushed to contents. In utils, Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/features/llms/runtime/server/content-llms.plugin.ts (1)
49-49:⚠️ Potential issue | 🟡 MinorTypo in comment: "emoty" → "empty".
- // Delete emoty auto generated sections + // Delete empty auto generated sections🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/features/llms/runtime/server/content-llms.plugin.ts` at line 49, Fix the typo in the inline comment: change the comment text "// Delete emoty auto generated sections" to read "// Delete empty auto generated sections" so the word "emoty" is corrected to "empty" in src/features/llms/runtime/server/content-llms.plugin.ts (look for the exact comment string in the file).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/features/llms/runtime/server/content-llms.plugin.ts`:
- Around line 79-81: The non-null assertion on markdown (returned from
generateDocument) can mask a real runtime undefined/empty-string; update the
logic around generateDocument(doc, options) and the push to contents so you
explicitly guard the result (e.g., check for null/undefined/empty string) before
pushing to contents, and handle the failure case deterministically (throw a
descriptive error or skip/log and continue) to avoid silently corrupting the LLM
output; look for the generateDocument call and the contents.push(markdown!) site
and replace the assertion with a conditional check and an explicit error or skip
path.
---
Outside diff comments:
In `@src/features/llms/runtime/server/content-llms.plugin.ts`:
- Line 49: Fix the typo in the inline comment: change the comment text "//
Delete emoty auto generated sections" to read "// Delete empty auto generated
sections" so the word "emoty" is corrected to "empty" in
src/features/llms/runtime/server/content-llms.plugin.ts (look for the exact
comment string in the file).
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/features/llms/runtime/server/content-llms.plugin.tssrc/features/llms/runtime/server/utils.ts
| const markdown = await generateDocument(doc, options) | ||
| contents.push(markdown) | ||
| contents.push(markdown!) | ||
| } |
There was a problem hiding this comment.
Non-null assertion masks a real runtime risk — guard instead.
If stringifyMarkdown resolves to undefined or an empty string (which TypeScript is already flagging as possible), markdown! is still undefined at runtime — the assertion only suppresses the compile error. Silently pushing undefined into contents will corrupt the LLMs full output without any error surface.
Prefer an explicit guard:
🛡️ Proposed fix
- const markdown = await generateDocument(doc, options)
- contents.push(markdown!)
+ const markdown = await generateDocument(doc, options)
+ if (markdown) {
+ contents.push(markdown)
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const markdown = await generateDocument(doc, options) | |
| contents.push(markdown) | |
| contents.push(markdown!) | |
| } | |
| const markdown = await generateDocument(doc, options) | |
| if (markdown) { | |
| contents.push(markdown) | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/features/llms/runtime/server/content-llms.plugin.ts` around lines 79 -
81, The non-null assertion on markdown (returned from generateDocument) can mask
a real runtime undefined/empty-string; update the logic around
generateDocument(doc, options) and the push to contents so you explicitly guard
the result (e.g., check for null/undefined/empty string) before pushing to
contents, and handle the failure case deterministically (throw a descriptive
error or skip/log and continue) to avoid silently corrupting the LLM output;
look for the generateDocument call and the contents.push(markdown!) site and
replace the assertion with a conditional check and an explicit error or skip
path.
import(variableName) pattern
🔗 Linked issue
❓ Type of change
📚 Description
📝 Checklist