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

Gemini CLI Companion PayloadTooLargeError: request entity too large.

Open javaer996 opened this issue 1 year ago • 7 comments

What happened?

When using the Gemini CLI alongside the Gemini CLI Companion in VSCode, the tool is unable to directly show the differences in modified files due to the error: "PayloadTooLargeError: request entity too large."

This error persists even with small files and minor (single-line) changes.

And it cannot accept or reject the changes.

What did you expect to happen?

It should correctly show file differences, support code review operations, and permit change management (accept/reject).

Client information

$ gemini /about
# paste output here

│ About Gemini CLI │ │ │ │ CLI Version 0.1.21 │ │ Git Commit 055fe46d │ │ Model gemini-2.5-pro │ │ Sandbox no sandbox │ │ OS darwin │ │ Auth Method OAuth

Login information

Loaded cached credentials. │ │ ⚠ Failed to check for updates: TypeError: Body is unusable: Body has already been read │ │ ℹ Authenticated via "oauth-personal". │ │ ✖ [ERROR] [IDEClient] IDE connection error. The connection was lost unexpectedly. Please try reconnecting by running /ide enable │ │ ✖ ========================================= │ │ This is an unexpected error. Please file a bug report using the /bug tool. │ │ CRITICAL: Unhandled Promise Rejection! │ │ ========================================= │ │ Reason: Error: Error POSTing to endpoint (HTTP 413): │ │ │ │ │ │ │ │ Error │ │ │ │ │ │

PayloadTooLargeError: request entity too large
at Lde

Anything else we need to know?

No response

javaer996 avatar Aug 18 '25 06:08 javaer996

Same issue here.

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Debug Console (ctrl+o to close)                                                                                                                                               │
│                                                                                                                                                                               │
│ ℹ Loaded cached credentials.                                                                                                                                                 │
│ ℹ Authenticated via "oauth-personal".                                                                                                                                        │
│ ⚠ Attempt 1 failed with status 429. Retrying with backoff... GaxiosError: [{                                                                                                 │
│      "error": {                                                                                                                                                               │
│        "code": 429,                                                                                                                                                           │
│        "message": "Resource exhausted. Please try again later. Please refer to https://cloud.google.com/vertex-ai/generative-ai/docs/error-code-429 for more details.",       │
│        "errors": [                                                                                                                                                            │
│          {                                                                                                                                                                    │
│            "message": "Resource exhausted. Please try again later. Please refer to https://cloud.google.com/vertex-ai/generative-ai/docs/error-code-429 for more details.",   │
│            "domain": "global",                                                                                                                                                │
│            "reason": "rateLimitExceeded"                                                                                                                                      │
│          }                                                                                                                                                                    │
│        ],                                                                                                                                                                     │
│        "status": "RESOURCE_EXHAUSTED"                                                                                                                                         │
│      }                                                                                                                                                                        │
│    }                                                                                                                                                                          │
│    ]                                                                                                                                                                          │
│        at Gaxios._request (/Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/gaxios/build/src/gaxios.js:142:23)                        │
│        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)                                                                                          │
│        at async OAuth2Client.requestAsync                                                                                                                                     │
│    (/Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/google-auth-library/build/src/auth/oauth2client.js:429:18)                       │
│        at async CodeAssistServer.requestStreamingPost                                                                                                                         │
│    (file:///Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/server.js:82:21)             │
│        at async CodeAssistServer.generateContentStream                                                                                                                        │
│    (file:///Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/server.js:24:23)             │
│        at async LoggingContentGenerator.generateContentStream                                                                                                                 │
│    (file:///Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/loggingContentGenerator.js:59:22)   │
│        at async retryWithBackoff                                                                                                                                              │
│    (file:///Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/utils/retry.js:62:20)                    │
│        at async GeminiChat.sendMessageStream                                                                                                                                  │
│    (file:///Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:281:36)               │
│        at async Turn.run                                                                                                                                                      │
│    (file:///Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/turn.js:40:36)                      │
│        at async GeminiClient.sendMessageStream                                                                                                                                │
│    (file:///Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/client.js:382:26) {                 │
│      config: {                                                                                                                                                                │
│        url: 'https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse',                                                                                   │
│        method: 'POST',                                                                                                                                                        │
│        params: { alt: 'sse' },                                                                                                                                                │
│        headers: {                                                                                                                                                             │
│          'Content-Type': 'application/json',                                                                                                                                  │
│          'User-Agent': 'GeminiCLI/v20.19.4 (darwin; arm64) google-api-nodejs-client/9.15.1',                                                                                  │
│          Authorization: '<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.',                                                                           │
│          'x-goog-api-client': 'gl-node/20.19.4'                                                                                                                               │
│        },                                                                                                                                                                     │
│        responseType: 'stream',                                                                                                                                                │
│        body: '<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.',                                                                                      │
│        signal: AbortSignal { aborted: false },                                                                                                                                │
│        paramsSerializer: [Function: paramsSerializer],                                                                                                                        │
│        validateStatus: [Function: validateStatus],                                                                                                                            │
│        errorRedactor: [Function: defaultErrorRedactor]                                                                                                                        │
│      },                                                                                                                                                                       │
│      response: {                                                                                                                                                              │
│        config: {                                                                                                                                                              │
│          url: 'https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse',                                                                                 │
│          method: 'POST',                                                                                                                                                      │
│          params: [Object],                                                                                                                                                    │
│          headers: [Object],                                                                                                                                                   │
│          responseType: 'stream',                                                                                                                                              │
│          body: '<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.',                                                                                    │
│          signal: [AbortSignal],                                                                                                                                               │
│          paramsSerializer: [Function: paramsSerializer],                                                                                                                      │
│          validateStatus: [Function: validateStatus],                                                                                                                          │
│          errorRedactor: [Function: defaultErrorRedactor]                                                                                                                      │
│        },                                                                                                                                                                     │
│        data: '[{\n' +                                                                                                                                                         │
│          '  "error": {\n' +                                                                                                                                                   │
│          '    "code": 429,\n' +                                                                                                                                               │
│          '    "message": "Resource exhausted. Please try again later. Please refer to https://cloud.google.com/vertex-ai/generative-ai/docs/error-code-429 for more           │
│    details.",\n' +                                                                                                                                                            │
│          '    "errors": [\n' +                                                                                                                                                │
│          '      {\n' +                                                                                                                                                        │
│          '        "message": "Resource exhausted. Please try again later. Please refer to https://cloud.google.com/vertex-ai/generative-ai/docs/error-code-429 for more       │
│    details.",\n' +                                                                                                                                                            │
│          '        "domain": "global",\n' +                                                                                                                                    │
│          '        "reason": "rateLimitExceeded"\n' +                                                                                                                          │
│          '      }\n' +                                                                                                                                                        │
│          '    ],\n' +                                                                                                                                                         │
│          '    "status": "RESOURCE_EXHAUSTED"\n' +                                                                                                                             │
│          '  }\n' +                                                                                                                                                            │
│          '}\n' +                                                                                                                                                              │
│          ']',                                                                                                                                                                 │
│        headers: {                                                                                                                                                             │
│          'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',                                                                                                         │
│          'content-length': '514',                                                                                                                                             │
│          'content-type': 'application/json; charset=UTF-8',                                                                                                                   │
│          date: 'Wed, 20 Aug 2025 09:02:03 GMT',                                                                                                                               │
│          server: 'ESF',                                                                                                                                                       │
│          'server-timing': 'gfet4t7; dur=429',                                                                                                                                 │
│          vary: 'Origin, X-Origin, Referer',                                                                                                                                   │
│          'x-content-type-options': 'nosniff',                                                                                                                                 │
│          'x-frame-options': 'SAMEORIGIN',                                                                                                                                     │
│          'x-xss-protection': '0'                                                                                                                                              │
│        },                                                                                                                                                                     │
│        status: 429,                                                                                                                                                           │
│        statusText: 'Too Many Requests',                                                                                                                                       │
│        request: {                                                                                                                                                             │
│          responseURL: 'https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse'                                                                          │
│        }                                                                                                                                                                      │
│      },                                                                                                                                                                       │
│      error: undefined,                                                                                                                                                        │
│      status: 429,                                                                                                                                                             │
│      [Symbol(gaxios-gaxios-error)]: '6.7.1'                                                                                                                                   │
│    }                                                                                                                                                                          │
│ ℹ Error: Failed to edit, could not find the string to replace.                                                                                                               │
│ ✖ [ERROR] [IDEClient] IDE connection error. The connection was lost unexpectedly. Please try reconnecting by running /ide enable                                             │
│ ✖ =========================================                                                                                                                                  │
│    This is an unexpected error. Please file a bug report using the /bug tool.                                                                                                 │
│    CRITICAL: Unhandled Promise Rejection!                                                                                                                                     │
│    =========================================                                                                                                                                  │
│    Reason: Error: Error POSTing to endpoint (HTTP 413): <!DOCTYPE html>                                                                                                       │
│    <html lang="en">                                                                                                                                                           │
│    <head>                                                                                                                                                                     │
│    <meta charset="utf-8">                                                                                                                                                     │
│    <title>Error</title>                                                                                                                                                       │
│    </head>                                                                                                                                                                    │
│    <body>                                                                                                                                                                     │
│    <pre>PayloadTooLargeError: request entity too large<br> &nbsp; &nbsp;at $de                                                                                                │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:202:421421)<br> &nbsp; &nbsp;at lKe                              │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:202:421188)<br> &nbsp; &nbsp;at RKe                              │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:202:427484)<br> &nbsp; &nbsp;at                                  │
│    /Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:202:432835<br> &nbsp; &nbsp;at C2.handleRequest                   │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:25945)<br> &nbsp; &nbsp;at g                                 │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:31023)<br> &nbsp; &nbsp;at                                   │
│    /Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:30622<br> &nbsp; &nbsp;at Rat                                 │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:32628)<br> &nbsp; &nbsp;at A                                 │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:30554)<br> &nbsp; &nbsp;at r.kp.handle                       │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:29909)<br> &nbsp; &nbsp;at t.ua.handle                       │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:35910)<br> &nbsp; &nbsp;at Server.t                          │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:236:744)<br> &nbsp; &nbsp;at Server.emit                         │
│    (node:events:518:28)<br> &nbsp; &nbsp;at parserOnIncoming (node:_http_server:1155:12)<br> &nbsp; &nbsp;at HTTPParser.parserOnHeadersComplete                               │
│    (node:_http_common:117:17)</pre>                                                                                                                                           │
│    </body>                                                                                                                                                                    │
│    </html>                                                                                                                                                                    │
│                                                                                                                                                                               │
│    Stack trace:                                                                                                                                                               │
│    Error: Error POSTing to endpoint (HTTP 413): <!DOCTYPE html>                                                                                                               │
│    <html lang="en">                                                                                                                                                           │
│    <head>                                                                                                                                                                     │
│    <meta charset="utf-8">                                                                                                                                                     │
│    <title>Error</title>                                                                                                                                                       │
│    </head>                                                                                                                                                                    │
│    <body>                                                                                                                                                                     │
│    <pre>PayloadTooLargeError: request entity too large<br> &nbsp; &nbsp;at $de                                                                                                │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:202:421421)<br> &nbsp; &nbsp;at lKe                              │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:202:421188)<br> &nbsp; &nbsp;at RKe                              │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:202:427484)<br> &nbsp; &nbsp;at                                  │
│    /Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:202:432835<br> &nbsp; &nbsp;at C2.handleRequest                   │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:25945)<br> &nbsp; &nbsp;at g                                 │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:31023)<br> &nbsp; &nbsp;at                                   │
│    /Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:30622<br> &nbsp; &nbsp;at Rat                                 │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:32628)<br> &nbsp; &nbsp;at A                                 │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:30554)<br> &nbsp; &nbsp;at r.kp.handle                       │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:29909)<br> &nbsp; &nbsp;at t.ua.handle                       │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:216:35910)<br> &nbsp; &nbsp;at Server.t                          │
│    (/Users/chou/.vscode-insiders/extensions/google.gemini-cli-vscode-ide-companion-0.1.21/dist/extension.cjs:236:744)<br> &nbsp; &nbsp;at Server.emit                         │
│    (node:events:518:28)<br> &nbsp; &nbsp;at parserOnIncoming (node:_http_server:1155:12)<br> &nbsp; &nbsp;at HTTPParser.parserOnHeadersComplete                               │
│    (node:_http_common:117:17)</pre>                                                                                                                                           │
│    </body>                                                                                                                                                                    │
│    </html>                                                                                                                                                                    │
│                                                                                                                                                                               │
│        at StreamableHTTPClientTransport.send                                                                                                                                  │
│    (file:///Users/chou/.nvm/versions/node/v20.19.4/lib/node_modules/@google/gemini-cli/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js:284:23)       │
│        at process.processTicksAndRejections (node:internal/process/task_queues:95:5) (x128)                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
~/Desktop/project/hoshi-lang (llvm*)                                               no sandbox (see /docs)                                                 gemini-2.5-pro (93% context left)

xiaokang00010 avatar Aug 20 '25 09:08 xiaokang00010

Same issue...

Gemini Cli version 0.1.22 installed with version npm 11.5.2 in mac OS version 15.5 (24F74)

vscode Version: 1.103.1 Commit: 360a4e4fd251bfce169a4ddf857c7d25d1ad40da Date: 2025-08-12T16:25:40.542Z Electron: 37.2.3 ElectronBuildId: 12035395 Chromium: 138.0.7204.100 Node.js: 22.17.0 V8: 13.8.500258-electron.0 OS: Darwin arm64 24.5.0

avansys2 avatar Aug 20 '25 12:08 avansys2

Same issue...

Gemini Cli version 0.1.22 installed with version npm 11.5.2 in mac OS version 15.5 (24F74)

vscode Version: 1.103.1 Commit: 360a4e4fd251bfce169a4ddf857c7d25d1ad40da Date: 2025-08-12T16:25:40.542Z Electron: 37.2.3 ElectronBuildId: 12035395 Chromium: 138.0.7204.100 Node.js: 22.17.0 V8: 13.8.500258-electron.0 OS: Darwin arm64 24.5.0

At the moment the only solution is to disable the ide using "/ide disable" . Then it works as pure terminal gemini cli.

avansys2 avatar Aug 21 '25 14:08 avansys2

I am also having this issue. I disabled IDE to see if it fixes it. I have closed my duplicate issue that has all my information and errors.

googleSandy avatar Aug 22 '25 22:08 googleSandy

Fixing this will require some investigation. I believe the payload limit could be coming from the default limit set in express / JSON parsing library. We'll need to investigate whether this limit can be increased. I've been able to repro by adding the following file to my repro & asking the CLI to edit it.

filler_text_150kb_80char.txt

skeshive avatar Sep 08 '25 14:09 skeshive

The issue now appears to be resolved in a similar multi-file context. Since I’m not entirely sure which step fixed the problem, here’s what I did:

Updated to the latest version of the Gemini CLI (v0.3.4; the previous version where I encountered the failure was v0.1.22). Uninstalled the Gemini VSCode extension (note: this is separate from the Gemini CLI). Opened a folder in VSCode and ran the Gemini CLI. Executed /ide enable. Ran the test, which now worked. Reinstalled the VSCode extension, and the fix persisted.

The VSCode version remains unchanged (v1.103.1). Since I ran this test multiple times after my last post and it always failed, I thought it was worth mentioning that it finally succeeded

avansys2 avatar Sep 08 '25 16:09 avansys2

@shishu314 and I were having difficulty reproing this through the CLI but we were able to repro by calling the IDE MCP server directly.

curl -X POST -H "Content-Type: application/json" -d '{"data": "'$(python3 -c 'print("a" * 200000)')'"}' http://localhost:55874/mcp

resulted in error: "PayloadTooLargeError: request entity too large"

Updating the express.json limit from 150 KB to 10 MB should fix the experience for most large files.

skeshive avatar Sep 08 '25 18:09 skeshive