Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary of ChangesHello @calchiwo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the robustness and security of the application by addressing potential prompt injection vulnerabilities and improving error handling practices. It introduces a mechanism to sanitize user-controlled input before it's incorporated into AI prompts, and refines error reporting by adopting stricter TypeScript types for caught exceptions, leading to more predictable and safer code execution. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request makes some great improvements. The switch from any to unknown in catch blocks significantly improves type safety, and the standardized error message extraction is a good step. Additionally, escaping user-provided content before including it in prompts is a crucial security hardening measure to prevent prompt injection.
I've left a couple of suggestions for further improvement: one related to reducing code duplication in error handling, and another to make the prompt content escaping even more robust. Overall, this is a solid contribution to improving the codebase's safety and maintainability.
| } catch (e: any) { | ||
| console.warn(`Warning: Could not read repo files: ${e?.message || e}`); | ||
| } catch (e: unknown) { | ||
| const message = e instanceof Error ? e.message : String(e); |
There was a problem hiding this comment.
This logic for extracting an error message is repeated in multiple catch blocks throughout this file. To improve maintainability and reduce code duplication, consider creating a utility function. For example:
function getErrorMessage(error: unknown): string {
if (error instanceof Error) {
return error.message;
}
return String(error);
}This function could then be called in each catch block, making the code cleaner and easier to maintain.
| @@ -1,3 +1,7 @@ | |||
| function escapeForPromptBlock(input: string): string { | |||
| return input.replace(/</g, "<").replace(/>/g, ">"); | |||
There was a problem hiding this comment.
While escaping < and > is crucial to prevent breaking out of the XML-style blocks, it's also a good practice to escape ampersands (&) to avoid potential misinterpretation by the LLM, as & is used to start character entities (e.g., <). To make this more robust, consider escaping ampersands as well. The order is important: & should be escaped first.
| return input.replace(/</g, "<").replace(/>/g, ">"); | |
| return input.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d32c16a38a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1 +0,0 @@ | |||
| {} | |||
There was a problem hiding this comment.
Retarget Dependabot before removing root npm manifest
Removing the root package.json leaves no npm manifest at /, but the existing npm Dependabot config still points to that directory (.github/dependabot.yml directory: "/"). In this state the npm update job has nothing to parse and dependency update automation for Node can stop/error, so this cleanup should be paired with either moving Dependabot to /node_version or keeping a minimal root manifest.
Useful? React with 👍 / 👎.
This PR hardens prompt construction by escaping repository-derived content
to prevent delimiter breakout in XML-style isolation blocks.
Improves type safety by replacing
anywithunknownin catch blocksand normalizing error extraction.
closes #141