-
Notifications
You must be signed in to change notification settings - Fork 336
fix: do not crash on SSE comment line #636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @ishymko, 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 resolves an issue where the client would unexpectedly terminate upon receiving comment lines within Server-Sent Events (SSE) streams. The solution involves a targeted modification to the streaming message processing logic, ensuring that empty data events, characteristic of SSE comments, are gracefully ignored. This enhancement improves the stability and resilience of the client's streaming capabilities, backed by new tests confirming the fix. Highlights
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.
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 effectively addresses a crash that occurs when processing Server-Sent Events (SSE) containing comment lines. The fix, applied to both jsonrpc and rest transports, correctly skips events with no data, preventing parsing errors. The addition of new tests for both transports using respx to mock SSE streams with comments is a great way to ensure the fix is working as expected. The changes are solid and improve the client's robustness. I have one minor suggestion to clean up some leftover debug code in a test file.
Description
The cause is florimondmanca/httpx-sse#35: using comments among events with
idfield causeshttpx-sseto emit an event with empty data.Although according to the standard (item 2) empty
buffershouldn't produce an event, with the way howhttpx-sseAPI is defined it may still be reasonable to emit an object with justretryfield for instance so that consumer could handle it. The standard definesretryfield handling outside of events dispatching, so in the context of this library it's up to the client (see here). That being said, even if comment handling bug is fixed, it still makes sense to add this check againstdatafield unconditionally without any TODOs.Tested by mocking one level lower to put
httpx-sseunder test as well as it's an integration issue.Fixes #540