gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

API Error (400): Request contains an invalid argument

Open keroshanpillay opened this issue 1 month ago • 9 comments

What happened?

Whilst gemini-cli was exploring my codebase, this error occurred:

[API Error: [{ "error": { "code": 400, "message": "Request contains an invalid argument.", "errors": [ { "message": "Request contains an invalid argument.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } } ]]

All subsequent model requests fail and there is no recourse.

What did you expect to happen?

Would expect (1) the error not to happen and (2) to heal.

Client information

  • CLI Version: 0.17.1
  • Git Commit: 1d51935fc
  • Session ID: 8b603b97-0022-4ede-bfdc-f2fbf93a50f8
  • Operating System: darwin v25.2.1
  • Sandbox Environment: no sandbox
  • Model Version: pro
  • Memory Usage: 423.3 MB

Login information

Google Account

Anything else we need to know?

No response

keroshanpillay avatar Nov 24 '25 18:11 keroshanpillay

Found possible duplicate issues:

  • #12823
  • #12869
  • #13665
  • #5468
  • #10663
  • #4921

If you believe this is not a duplicate, please remove the status/possible-duplicate label.

gemini-cli[bot] avatar Nov 24 '25 18:11 gemini-cli[bot]

could you provide more details? What was the request that triggered this error?

SandyTao520 avatar Nov 24 '25 19:11 SandyTao520

Sure @SandyTao520

There were only two prompts in this conversation. I've had to redact some items, but this should give you an idea. I received continual 400s after (2). The response to (1) was good though.

1

read [document_1] [doc_2] [doc_3] and let me what this system is and how it works please

2

Excellent. So [file] is [x] bytes over the bytecode limit. Could you provide ideas to bring it under? Note: we need to keep function [redacted] due to [reason]

keroshanpillay avatar Nov 24 '25 19:11 keroshanpillay

This is easily reproducible by sending an invalid .wav file type.

Try this:

echo "Test audio file content" > test_audio_file.wav
gemini
# wait for Gemini to load, and send the following prompt
> What is the content of this file @test_audio_file.wav?

Output is:

✕ [API Error: [{
    "error": {
      "code": 400,
      "message": "Request contains an invalid argument.",
      "errors": [
        {
          "message": "Request contains an invalid argument.",
          "domain": "global",
          "reason": "badRequest"
        }
      ],
      "status": "INVALID_ARGUMENT"
    }
  }
  ]]

Also works by simply prompting it inline:

echo "Test audio file content" > test_audio_file.wav
gemini -p "What is the content of this file @test_audio_file.wav?"

I'm using v0.18.4 on a machine running Linux Mint 22 machine.

Checking other threads, I see people mentioning MCP servers could be the cause of it: I'm not using any MCP servers.

My settings.json file:

{
  "ide": {
    "hasSeenNudge": true,
    "enabled": true
  },
  "security": {
    "auth": {
      "selectedType": "oauth-personal"
    }
  },
  "general": {
    "previewFeatures": true
  },
  "ui": {
    "showMemoryUsage": true,
    "showLineNumbers": true,
    "showCitations": true,
    "showModelInfoInChat": true
  }
}

MrLeonix avatar Nov 30 '25 09:11 MrLeonix

The problem seems to be with gemini-3-pro-preview. When requesting it to use gemini-2.5-flash model, then it works - at least I get a text response, not an error.

MrLeonix avatar Nov 30 '25 09:11 MrLeonix

Hi @MrLeonix , i don't believe we support sending .wav files, have you tried sending a normal request without a file attached or a .txt,.md file ?

galz10 avatar Dec 04 '25 23:12 galz10

Hi @MrLeonix , i don't believe we support sending .wav files, have you tried sending a normal request without a file attached or a .txt,.md file ?

Hey, @galz10 ! Thanks for replying.

I mean: the point is not whether it supports *.wav or not, but how the model behaves when receiving an invalid file. As mentioned, it keeps on throwing errors, when it should tell the user the file is invalid, or just say it can't process that file.

If you try that, you'll see that once that file is in the context, you lose your session. You always get the same error as response, and the only way to fix it is closing the session and starting a new one. That's the bug. The *.wav example is just an easy way to reproduce it, not the root cause.

MrLeonix avatar Dec 04 '25 23:12 MrLeonix

+1 this lack of further error details is infuriating to debug

arjunchint avatar Dec 05 '25 23:12 arjunchint

I've been seeing this error often. At least 3 time in the last 3 hours.

╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ ✓ SearchText 'offcanvas-end' within frontend.v3/src │ │ │ │ Found 25 matches │ │ │ │ ✓ ReadFile frontend.v3/src/styles.css │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ✕ [API Error: [{ "error": { "code": 400, "message": "Request contains an invalid argument.", "errors": [ { "message": "Request contains an invalid argument.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } } ]]

sabelosimelane avatar Dec 08 '25 19:12 sabelosimelane