Skip to content

[Bug] Numeric enum values cause 400 Bad Request in Gemini API #409

@nxxxsooo

Description

@nxxxsooo

Description

When using opencode-antigravity-auth with the Gemini API, the toGeminiSchema function does not stringify numeric enum values, causing a 400 Bad Request error.

Error Message

Schema.properties[name].enum[2]: enum value must be a STRING

The API returns errors like:

  • 1.enum[0]: enum value must be a STRING
  • 1.enum[1]: enum value must be a STRING

Root Cause

In gemini.js, the toGeminiSchema function at lines 87-89:

else if (key === "enum" && Array.isArray(value)) {
    result[key] = value; // ❌ Keeps numeric enum values as-is
}

Suggested Fix

else if (key === "enum" && Array.isArray(value)) {
    result[key] = value.map(v => String(v)); // ✅ Convert all values to strings
}

Environment

  • Plugin version: 1.4.6
  • OpenCode version: latest
  • API: Gemini (Google AI)

Workaround

Manually editing gemini.js in the cached plugin directory works temporarily, but gets overwritten on plugin updates.

Thanks for maintaining this plugin! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/compatCompatibility with OpenCode, DCPbugSomething isn't workingduplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions