-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(cli):detailed error message on sse stream specifying stacktrack,error type on client side as well #4248
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
base: main
Are you sure you want to change the base?
Conversation
…error type on client side as well
Summary of ChangesHello @DineshThumma9, 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 significantly improves the error handling for Server-Sent Events (SSE) streams within the CLI. Previously, errors during SSE streaming would result in a generic 200 OK response with minimal error information. The updated implementation now provides a structured JSON error object containing the error type, message, and a timestamp. Crucially, when debug logging is active, a full stack trace is also included, offering much richer diagnostic data to client applications. This change directly addresses issue #4244 by making SSE stream errors more transparent and actionable. Highlights
🧠 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 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 enhances the error handling in SSE streams by providing more detailed error messages, including the error type and stack trace when debug mode is enabled. It also includes a new unit test to verify the structured JSON error response. The changes look good and improve the debugging experience.
| logger.debug( | ||
| "Generated event in agent run streaming: %s", sse_event | ||
| "Generated event in agent run streaming: %s", | ||
| sse_event, | ||
| ) |
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.
Consider using logger.debug with the extra parameter to include additional context, such as the session ID or user ID, in the log message. This can aid in debugging and tracing issues in multi-user environments.
For example:
logger.debug("Generated event in agent run streaming: %s", sse_event, extra={"session_id": req.session_id, "user_id": req.user_id})
src/google/adk/cli/adk_web_server.py
Outdated
| except Exception as e: | ||
| logger.exception("Error in event_generator: %s", e) | ||
| # Yield a proper Event object for the error | ||
| logger.debug("Exception in agent run streaming: %s", e) |
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.
|
/gemini review |
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
The pull request significantly enhances the error reporting mechanism for Server-Sent Events (SSE) streams in the CLI web server. By introducing structured JSON error details, including error type, message, timestamp, and an optional stack trace (when debug logging is enabled), the changes provide much more actionable information to clients. This is a valuable improvement for debugging and client-side error handling. The addition of session_id and user_id to debug logs also improves traceability. The new test case thoroughly validates these changes under different logging configurations.
However, there are missing imports for json, time, traceback, and datetime which are used in the new error handling logic. These need to be added to ensure the code runs correctly. Additionally, using an ISO-formatted timestamp for error details would improve readability and consistency for client consumption.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
SSE Streaming even when error occurs sends 200 request and a simplified Error Response
2.Solution
By default see always sends 200 ok response so atleast to give better context of error
I have added a json of error_details which includes error type ,error name and stacktrack if debug is enabled
Testing Plan
Unit Tests:
All Unit test passed
Checklist