Skip to content

Conversation

@DineshThumma9
Copy link
Contributor

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

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:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

All Unit test passed

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Enhanced Server-Sent Events (SSE) Error Reporting: The pull request significantly improves error handling for SSE streams by providing detailed, structured JSON error objects instead of simplified messages.
  • Detailed Error Information: Error objects now include error_type, error_message, and a timestamp for better context.
  • Conditional Stack Trace Inclusion: A full stacktrace is now conditionally included in the error object when debug logging is enabled, aiding in quicker diagnosis.
  • New Unit Test for Error Handling: A new unit test (test_agent_run_sse_error_details) has been added to thoroughly validate the structured error output for SSE streams under both debug and non-debug conditions.

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

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.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jan 23, 2026
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 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.

Comment on lines 1557 to 1560
logger.debug(
"Generated event in agent run streaming: %s", sse_event
"Generated event in agent run streaming: %s",
sse_event,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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})

Comment on lines 1562 to 1563
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

It's good to use logger.debug here since it's an exception in a streaming context, but consider including the traceback information in the debug log as well. This can be done using exc_info=True.

logger.debug("Exception in agent run streaming: %s", e, exc_info=True)

@DineshThumma9
Copy link
Contributor 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

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.

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

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSE endpoint: run_sse does not propagate exceptions or non-2xx status codes

2 participants