Skip to content

ci(triage): fix comment spam by separating internal explanation from public comment#26672

Open
itzzSPcoder wants to merge 5 commits intogoogle-gemini:mainfrom
itzzSPcoder:fix/triage-comment-spam
Open

ci(triage): fix comment spam by separating internal explanation from public comment#26672
itzzSPcoder wants to merge 5 commits intogoogle-gemini:mainfrom
itzzSPcoder:fix/triage-comment-spam

Conversation

@itzzSPcoder
Copy link
Copy Markdown

This PR fixes an issue where the scheduled triage bot was unconditionally posting its internal reasoning as a public comment on all triaged issues. By introducing a new \comment\ field in the JSON schema, the bot will now only comment when it explicitly needs to ask the user for more information.

@itzzSPcoder itzzSPcoder requested review from a team as code owners May 7, 2026 20:15
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 refactors the authentication error handling mechanism to improve the user experience and security of the CLI. By centralizing the detection and formatting of authentication errors, the changes ensure consistent and safe error reporting across the application. Note: The provided PR description regarding comment spam appears to be unrelated to the actual code changes, which focus exclusively on authentication error management.

Highlights

  • Authentication Error Handling: Centralized authentication error formatting and detection logic to provide clearer, more actionable terminal feedback.
  • Security Sanitization: Implemented sanitization for authentication error messages to strip control characters and prevent potential terminal injection.
  • Code Refactoring: Simplified error handling flow in non-interactive authentication validation by consolidating logic into the updated handleError utility.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/gemini-automated-issue-triage.yml
    • .github/workflows/gemini-scheduled-issue-triage.yml
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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.

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
Copy Markdown
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 centralizes and improves authentication error handling by introducing formatAuthError and isAuthRelatedError utilities. It updates handleError to provide more user-friendly terminal output and consistent exit behavior for authentication failures. Feedback suggests using the AuthType enum instead of hardcoded strings, passing pre-parsed error messages to formatting functions to avoid redundant parsing, and preserving original error types when generating JSON output to maintain diagnostic metadata.

Comment thread packages/cli/src/utils/errors.ts Outdated
char === '\n' || char === '\r' || char === '\t' ? char : ''
);

const fix = authType === 'google-cloud'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The check authType === 'google-cloud' uses a hardcoded string that does not match the AuthType values used elsewhere in the codebase (e.g., LOGIN_WITH_GOOGLE, COMPUTE_ADC, USE_VERTEX_AI). This will likely cause the wrong 'Fix' instructions to be displayed for Google Cloud-based authentication methods. You should use the AuthType enum/object to perform this check correctly.

Comment thread packages/cli/src/utils/errors.ts Outdated
);

if (isAuthError) {
errorMessage = formatAuthError(error, config.getContentGeneratorConfig()?.authType);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

formatAuthError is being passed the raw error object, which causes it to re-parse the error message. However, parseAndFormatApiError has already been called on line 114, which likely provides a more accurate and sanitized message (e.g., by handling specific API error structures). Passing the already-parsed errorMessage to formatAuthError ensures that the most descriptive reason is preserved in the final output.

Suggested change
errorMessage = formatAuthError(error, config.getContentGeneratorConfig()?.authType);
errorMessage = formatAuthError(errorMessage, config.getContentGeneratorConfig()?.authType);

Comment on lines 145 to 149
const formattedError = formatter.formatError(
error instanceof Error ? error : new Error(getErrorMessage(error)),
new Error(errorMessage),
errorCode,
config.getSessionId(),
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Wrapping the formatted message in a generic new Error(errorMessage) when generating JSON output causes the loss of the specific error type (e.g., FatalTurnLimitedError). This makes the JSON output less useful for programmatic consumption or IDE integrations that rely on the error type to provide specific handling. Consider preserving the original error's type while updating its message.

Suggested change
const formattedError = formatter.formatError(
error instanceof Error ? error : new Error(getErrorMessage(error)),
new Error(errorMessage),
errorCode,
config.getSessionId(),
);
const errorToFormat = error instanceof Error ? error : new Error(getErrorMessage(error));
errorToFormat.message = errorMessage;
const formattedError = formatter.formatError(
errorToFormat,
errorCode,
config.getSessionId(),
);
References
  1. When catching exceptions, log the detailed error for debugging instead of providing only a generic error message.

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label May 7, 2026
Addresses Gemini Code Assist review feedback by sanitizing ANSI escape codes
from authentication error reasons. Also adds context-aware fix instructions
based on the AuthType.
@itzzSPcoder itzzSPcoder force-pushed the fix/triage-comment-spam branch from 7557dab to 813b89d Compare May 7, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant