Skip to content

Conversation

@lollipopkit
Copy link
Contributor

Fixed:
image

@gemini-code-assist
Copy link

Summary of Changes

Hello @lollipopkit, 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 implements a fix for the Claude translator by enhancing the validation and normalization of tool parameter schemas. A new function, normalizeToolParameters, has been added to ensure that all tool input_schema definitions are robustly converted into valid JSON objects with a properties field. This change prevents potential errors and improves the reliability of tool integration by standardizing schema structures, addressing the issue of malformed or incomplete schema definitions.

Highlights

  • New Schema Normalization Function: Introduced a new utility function, normalizeToolParameters, to ensure tool parameter schemas are consistently well-formed.
  • Robust Tool Parameter Handling: The ConvertClaudeRequestToCodex function now utilizes normalizeToolParameters to process the input_schema before assigning it to a tool's parameters.
  • Schema Validation: The normalization function handles empty, null, or invalid JSON inputs, defaults missing schema types to 'object', and guarantees that object schemas always contain a 'properties' map, even if empty.
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

@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 fixes an issue where a tool schema without a properties field would cause an error. The fix introduces a normalizeToolParameters function to ensure that any object-type tool schema has at least an empty properties map.

My review focuses on the new normalizeToolParameters function. While the current implementation fixes the reported issue, it has some edge cases that could lead to other problems. I've provided a suggestion to make the function more robust by handling non-object JSON inputs and schemas with types other than object.

Comment on lines +340 to +354
raw = strings.TrimSpace(raw)
if raw == "" || raw == "null" || !gjson.Valid(raw) {
return `{"type":"object","properties":{}}`
}
schema := raw
result := gjson.Parse(raw)
schemaType := result.Get("type").String()
if schemaType == "" {
schema, _ = sjson.Set(schema, "type", "object")
schemaType = "object"
}
if schemaType == "object" && !result.Get("properties").Exists() {
schema, _ = sjson.SetRaw(schema, "properties", `{}`)
}
return schema

Choose a reason for hiding this comment

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

high

The implementation of normalizeToolParameters can be made more robust. There are two potential issues:

  1. It doesn't correctly handle valid JSON that is not an object (e.g., [], "a string"). This can cause silent failures in sjson and pass an invalid schema downstream.
  2. It doesn't handle schemas that have a type other than "object" (e.g., "type": "string"). These are passed through as-is and will likely cause errors in the target API, which expects an object with properties.

The suggested change refactors the function to address both issues by ensuring the schema is a JSON object and has the correct structure before returning.

	raw = strings.TrimSpace(raw)
	result := gjson.Parse(raw)
	schemaType := result.Get("type").String()

	if !result.IsObject() || (schemaType != "" && schemaType != "object") {
		return `{"type":"object","properties":{}}`
	}

	schema := raw
	if schemaType == "" {
		schema, _ = sjson.Set(schema, "type", "object")
	}

	if !result.Get("properties").Exists() {
		schema, _ = sjson.SetRaw(schema, "properties", `{}`)
	}
	return schema

@luispater luispater changed the base branch from main to dev November 16, 2025 04:19
@luispater luispater merged commit faa483b into router-for-me:dev Nov 16, 2025
1 check failed
diyism pushed a commit to diyism/CLI2API that referenced this pull request Nov 26, 2025
fix(claude translator): guard tool schema properties
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.

2 participants