Refactoring of context and request entry into a single thing prompt#131
Refactoring of context and request entry into a single thing prompt#131ThePrimeagen merged 1 commit intomasterfrom
Conversation
|
You have run out of free Bugbot PR reviews for this billing cycle. This will reset on March 8. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
| local ok, visual_data = pcall(self.visual_data, self) | ||
| if ok then | ||
| local f_loc = | ||
| self._99.prompts.get_file_location(self.full_path, visual_data.range) | ||
| table.insert(self.agent_context, f_loc) | ||
| table.insert( | ||
| self.agent_context, | ||
| self._99.prompts.get_range_text(visual_data.range) | ||
| ) |
There was a problem hiding this comment.
Bug: Calling finalize() on a visual context without an updated range uses a default Range.zero(), leading to incorrect context data being generated.
Severity: MEDIUM
Suggested Fix
Add a validation check inside the finalize() function. Before processing visual_data, verify that visual_data.range is not the default Range.zero(). If the range is invalid, either log an error and abort or throw an error to prevent the generation of incorrect context.
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: lua/99/prompt.lua#L392-L400
Potential issue: The `Prompt.visual()` function initializes a context with a default
`range` set to `Range.zero()`. If `finalize()` is called on this visual context without
the range being updated by `over_range()`, the `get_range_text()` function proceeds with
this zero-range. This causes an empty or incorrect text selection to be extracted and
sent to the AI provider. While the main production path appears to correctly update the
range, the lack of validation in `finalize()` allows for code paths to exist that can
generate incorrect context for visual prompts.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
this is not real, on overrange line 24 we set the range, but i think a better version would be to require range to be passed into the prompt creation. will do that to prevent this type of really sharp edge from accidentally appearing
@codegirl-007 just FYI i have made a big change. Its still partially done