Skip to content

ChatGoogleGenerativeAI: Invalid JSON payload received #7711

Open
@m-khashaba4

Description

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code


export async function init(commit: string) {
    const model = new ChatGoogleGenerativeAI({
        model: "gemini-2.0-flash",
        temperature: 1.0,
    });
    
    return (
        await PullFromLangSmith<typeof ModelInput, typeof ModelOu1put>(
            `node:${commit}`,
            ModelInput,
            ModelOu1put,
            model,
            true
        )
    )
} 

Error Message and Stack Trace (if applicable)

{"status":400,"statusText":"Bad Request","errorDetails":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"tools[0].function_declarations[0].parameters","description":"Invalid JSON payload received. Unknown name \"title\" at 'tools[0].function_declarations[0].parameters': Cannot find field."},{"field":"tools[0].function_declarations[0].parameters","description":"Invalid JSON payload received. Unknown name \"additionalProperties\" at 'tools[0].function_declarations[0].parameters': Cannot find field."}]}],"attemptNumber":1,"retriesLeft":6},"trace":"Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse: [400 Bad Request] Invalid JSON payload received. Unknown name \"title\" at 'tools[0].function_declarations[0].parameters': Cannot find field.\nInvalid JSON payload received. Unknown name \"additionalProperties\" at 'tools[0].function_declarations[0].parameters': Cannot find field. [{\"@type\":\"type.googleapis.com/google.rpc.BadRequest\",\"fieldViolations\":[{\"field\":\"tools[0].function_declarations[0].parameters\",\"description\":\"Invalid JSON payload received. Unknown name \\\"title\\\" at 'tools[0].function_declarations[0].parameters': Cannot find field.\"},{\"field\":\"tools[0].function_declarations[0].parameters\",\"description\":\"Invalid JSON payload received. Unknown name \\\"additionalProperties\\\" at 'tools[0].function_declarations[0].parameters': Cannot find field.\"}]}]\n at handleResponseNotOk (../node_modules/@google/generative-ai/dist/index.js:414:11)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async makeRequest (../node_modules/@google/generative-ai/dist/index.js:387:9)\n at async generateContentStream (../node_modules/@google/generative-ai/dist/index.js:827:22)\n at async ../node_modules/@langchain/google-genai/dist/chat_models.cjs:681:32\n at async RetryOperation._fn (../node_modules/p-retry/index.js:50:12)","errorMessage":"[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse: [400 Bad Request] Invalid JSON payload received. Unknown name \"title\" at 'tools[0].function_declarations[0].parameters': Cannot find field.\nInvalid JSON payload received. Unknown name \"additionalProperties\" at 'tools[0].function_declarations[0].parameters': Cannot find field. [{\"@type\":\"type.googleapis.com/google.rpc.BadRequest\",\"fieldViolations\":[{\"field\":\"tools[0].function_declarations[0].parameters\",\"description\":\"Invalid JSON payload received. Unknown name \\\"title\\\" at 'tools[0].function_declarations[0].parameters': Cannot find field.\"},{\"field\":\"tools[0].function_declarations[0].parameters\",\"description\":\"Invalid JSON payload received. Unknown name \\\"additionalProperties\\\" at 'tools[0].function_declarations[0].parameters': Cannot find field.\"}]}]"}

Description

when invoking i get this error

System Info

"@langchain/google-genai": "^0.1.8",

Activity

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

Metadata

Assignees

No one assigned

    Labels

    auto:bugRelated to a bug, vulnerability, unexpected error with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions