Skip to content

fix: prevent KeyError in _handle_abort_req when request already completed#21223

Closed
yang1002378395-cmyk wants to merge 1 commit intosgl-project:mainfrom
yang1002378395-cmyk:fix-abort-keyerror-21173
Closed

fix: prevent KeyError in _handle_abort_req when request already completed#21223
yang1002378395-cmyk wants to merge 1 commit intosgl-project:mainfrom
yang1002378395-cmyk:fix-abort-keyerror-21173

Conversation

@yang1002378395-cmyk
Copy link
Copy Markdown
Contributor

Fixes #21173

Problem: _handle_abort_req crashes with KeyError when trying to abort a request that has already completed.

Fix: Use dict.get() with None check, matching the pattern in _handle_batch_output.

…eted

Issue sgl-project#21173: If the request has already finished and been cleaned up
from rid_to_state before the abort message arrives, accessing
self.rid_to_state[recv_obj.rid] raises KeyError.

Fix: Use .get() with None check, matching the pattern used in
_handle_batch_output (~line 1533).
@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 addresses a KeyError that could occur in the tokenizer manager when an abort request was received for a request that had already finished processing. The change ensures that the system gracefully handles such scenarios by checking for the request's existence before attempting to access its state, thereby improving the robustness of request termination.

Highlights

  • KeyError Prevention: Implemented a check in _handle_abort_req to prevent a KeyError when attempting to abort a request that has already been completed and cleaned up.
  • Robust Abort Handling: Switched from direct dictionary access (self.rid_to_state[key]) to dict.get(key) with a None check, aligning with existing patterns for handling potentially missing request states.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 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 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.

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 prevents a KeyError in _handle_abort_req that could occur if an abort request is processed after the target request has already completed. The fix involves using dict.get() for safer dictionary access. I have reviewed the change and have no further suggestions.

@yang1002378395-cmyk
Copy link
Copy Markdown
Contributor Author

This fix is now included in PR #21224 which addresses #21168, #21171, and #21173 together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_handle_abort_req crashes with KeyError when request already completed

1 participant