Skip to content

fix(go): fixed panic when stream value is nil#4102

Merged
apascal07 merged 1 commit intomainfrom
ap/go-stream-fix
Jan 11, 2026
Merged

fix(go): fixed panic when stream value is nil#4102
apascal07 merged 1 commit intomainfrom
ap/go-stream-fix

Conversation

@apascal07
Copy link
Copy Markdown
Collaborator

Checklist (if applicable):

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @apascal07, 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 potential runtime panic that could occur in AI generation and prompting streaming operations when an intermediate streamValue was unexpectedly nil. It introduces a new, comprehensive IsNil utility function to robustly check for nil values across various Go types. This function is then integrated into the streaming logic to safely skip yielding nil values, thereby preventing crashes and improving the overall stability and robustness of the streaming process.

Highlights

  • Robust Nil Checking: Introduced a new generic IsNil utility function in go/internal/base/misc.go that uses reflection to accurately determine if a value of any type (including pointers, interfaces, maps, slices, channels, and functions) is nil.
  • Panic Prevention in Streaming: Implemented checks using the new base.IsNil function within go/ai/generate.go and go/ai/prompt.go to prevent panics. The system now gracefully skips yielding a StreamValue if the streamValue itself is nil, particularly useful for handling incomplete or unparseable outputs during streaming.
  • Improved Stream Resilience: Enhanced the resilience of AI generation and prompting streams by ensuring that nil intermediate results do not lead to runtime errors, thus improving the stability of streaming operations.

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

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 addresses a panic that occurs during data streaming when a parsed value is nil, which can happen with incomplete data like partial JSON. The fix introduces a robust base.IsNil helper function that uses reflection to correctly check for nil across various Go types. This check is then applied in GenerateDataStream and DataPrompt.ExecuteStream before yielding a streamed value, preventing the panic. The changes are logical and well-implemented. I've added one suggestion to improve test coverage for the new utility function.

Comment thread go/internal/base/misc.go
@apascal07 apascal07 merged commit 68fd12e into main Jan 11, 2026
6 checks passed
@apascal07 apascal07 deleted the ap/go-stream-fix branch January 11, 2026 00:50
@yesudeep yesudeep mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants