Skip to content

Conversation

@greycodee
Copy link

@greycodee greycodee commented Jul 1, 2025

TLDR

image

Dive Deeper

Reviewer Test Plan

Testing Matrix

🍏 πŸͺŸ 🐧
npm run βœ… βœ… βœ…
npx βœ… βœ… βœ…
Docker βœ… βœ… βœ…
Podman βœ… - -
Seatbelt βœ… - -

Linked issues / bugs

fix: #2819

@greycodee greycodee requested a review from a team as a code owner July 1, 2025 13:54
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @greycodee, 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 addresses a user experience issue by enhancing the /chat save command. It introduces necessary input validation for the tag argument, ensuring that users are immediately notified with clear error messages if they provide an invalid or missing tag, thus preventing silent failures and improving the command's usability.

Highlights

  • Input Validation: Implemented validation for the tag argument of the /chat save command. The tag must now conform to the regex ^[a-zA-Z0-9_-]+$, allowing only letters, numbers, hyphens, and underscores.
  • Improved User Feedback: Added explicit error messages to inform users when a tag is invalid or missing for the /chat save command. This prevents the command from silently failing and provides clear guidance to the user.
Using Gemini Code Assist

The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and 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 to provide feedback.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly adds validation to the /chat save command to prevent it from failing silently with invalid tags. This also implicitly fixes a critical path traversal security vulnerability. My review points out that the same vulnerability exists in the /chat resume command and recommends extending the fix to cover that case as well.

@gemini-cli gemini-cli bot added kind/bug priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality labels Jul 3, 2025
Copy link
Collaborator

@abhipatel12 abhipatel12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Sorry this took me so long to get to. This looks great!

Can we add some test cases that validate/test this?

@greycodee
Copy link
Author

Hey! Sorry this took me so long to get to. This looks great!

Can we add some test cases that validate/test this?

I have now added the relevant tests for the chat command.

@greycodee greycodee requested a review from abhipatel12 July 4, 2025 01:36
@greycodee
Copy link
Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a silent failure in the /chat save command by adding validation for the provided tag. A high-severity suggestion was added to also validate the length of the tag to prevent potential filesystem errors with overly long filenames, which could lead to an application crash. This improves the robustness of the fix.

Comment on lines +735 to 742
const validTagRegex = /^[a-zA-Z0-9_-]+$/;
if (!validTagRegex.test(tag)) {
addMessage({
type: MessageType.ERROR,
content: 'Invalid tag. Only letters, numbers, hyphens, and underscores are allowed.',
timestamp: new Date(),
});
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current validation for the tag checks for valid characters but not for length. An excessively long tag could lead to errors when creating the checkpoint file, as file systems have filename length limitations. Enforce a reasonable maximum length for the tag to prevent potential filesystem errors and application crashes.

Suggested change
const validTagRegex = /^[a-zA-Z0-9_-]+$/;
if (!validTagRegex.test(tag)) {
addMessage({
type: MessageType.ERROR,
content: 'Invalid tag. Only letters, numbers, hyphens, and underscores are allowed.',
timestamp: new Date(),
});
return;
const validTagRegex = /^[a-zA-Z0-9_-]{1,200}$/;
if (!validTagRegex.test(tag)) {
addMessage({
type: MessageType.ERROR,
content:
'Invalid tag. Tag must be 1-200 characters and contain only letters, numbers, hyphens, and underscores.',
timestamp: new Date(),
});
return;
}

@greycodee
Copy link
Author

@abhipatel12 I found that your refactored code has been merged into #3175. Is the current PR still needed?

@abhipatel12
Copy link
Collaborator

Hey @greycodee! I didn't change any of the logic within /chat for this initial migration in that refactor. Would you be able to see if main still has the issue you were tackling?

@greycodee
Copy link
Author

@abhipatel12 I merged the refactored command code and modified the test code of the /chat command

@abhipatel12
Copy link
Collaborator

Awesome, thanks for doing that. I will have some time to review later today!

@gemini-cli gemini-cli bot added kind/issue-triage priority/p2 Important but can be addressed in a future release. and removed priority/p1 Important and should be addressed in the near term. labels Jul 17, 2025
@greycodee
Copy link
Author

The code version has been refactored and this branch is no longer needed.

@greycodee greycodee closed this Jul 30, 2025
@greycodee greycodee deleted the fix/chat-save-tag-format branch July 30, 2025 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] /chat save command silently fails on invalid tags

2 participants