Skip to content

fix(gemini): remove metadata and disable inbound query merge#1124

Merged
looplj merged 1 commit intolooplj:release/v0.9.xfrom
rainive:fix/gemini-openai-query-metadata
Mar 22, 2026
Merged

fix(gemini): remove metadata and disable inbound query merge#1124
looplj merged 1 commit intolooplj:release/v0.9.xfrom
rainive:fix/gemini-openai-query-metadata

Conversation

@rainive
Copy link
Copy Markdown
Contributor

@rainive rainive commented Mar 22, 2026

Summary

Fix Gemini OpenAI request 400 errors.

Closes #1123

Changes

  • remove metadata from outbound body
  • disable inbound query merge

Result

Avoid forwarding unsupported fields like beta and metadata.

@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 and resolves 400 errors that occurred during interactions with the Gemini OpenAI endpoint. The core changes involve modifying the outbound request structure to exclude unsupported fields, specifically 'metadata', and disabling the inbound query merge functionality. These adjustments ensure that requests conform to the Gemini API's expectations, thereby improving the reliability and success rate of API calls.

Highlights

  • Gemini OpenAI Request Fix: Resolved 400 errors when making requests to the Gemini OpenAI endpoint by preventing the forwarding of unsupported fields.
  • Metadata Removal: Removed the 'metadata' field from the outbound request body, as the Gemini OpenAI endpoint does not accept it.
  • Inbound Query Merge Disabled: Disabled inbound query merging for Gemini OpenAI requests to ensure compatibility and prevent issues with unsupported query parameters.
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 addresses 400 errors from the Gemini OpenAI endpoint by removing the metadata field and disabling inbound query merging. The changes are logical and directly address the issue. My review includes suggestions to enhance the test suite to ensure these fixes are robust and prevent future regressions by properly testing the new behavior.

Comment on lines +305 to +306
// Gemini OpenAI endpoint does not accept metadata.
req.Metadata = nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This change correctly nullifies the metadata on the request. To ensure this fix is properly tested and to prevent regressions, please consider updating the test case (valid chat completion request in outbound_test.go) to cover the case where the original request has metadata. Verify that it's stripped out.

Headers: headers,
Body: body,
Auth: auth,
SkipInboundQueryMerge: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This change correctly sets SkipInboundQueryMerge to true. To prevent future regressions, please add a test assertion in outbound_test.go to verify that SkipInboundQueryMerge is set to true on the returned httpclient.Request object.

@looplj looplj merged commit 83d6608 into looplj:release/v0.9.x Mar 22, 2026
2 checks passed
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.

[Bug/错误]: Gemini OpenAI 渠道请求 400,报错 Unknown name "beta" / "metadata"

2 participants