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

API Error: Unexpected line format in response:

Open chingchun94 opened this issue 1 year ago • 16 comments

Describe the bug When asking for "how to run in sandbox", it returns API Error

Client information Windows

Windows PowerShell Text.txt

Image

Additional context Nope

chingchun94 avatar Jun 25 '25 16:06 chingchun94

I think it should prompt the user to login/provide API instead of returning the error? Didnt experience this when using WSL + windows

chingchun94 avatar Jun 25 '25 16:06 chingchun94

I think in your example the request fully succeeded on the "how to run in sandbox?" and only failed on the subsequent "how does the restriction work?" It would have failed on the first if your authentication wasn't configured

veilm avatar Jun 25 '25 16:06 veilm

same

bymechul avatar Jun 25 '25 17:06 bymechul

https://developers.google.com/gemini-code-assist/resources/available-locations Gemini CLI / Code assist plugin might be not available for you, if your personal gmail account bounded to country not in this list ^^.

alex-orlovskyi avatar Jun 25 '25 19:06 alex-orlovskyi

The same error occurred to me halfway through a prompt.

(Original prompt: "create an ecommerce website with plain php, html, css, js and use sqlite as db")

I just asked it to continue the previous command and it successfully did.

Model: gemini-2.5-flash

System: WSL2 (Ubuntu)

Image

adhhamofficial avatar Jun 26 '25 16:06 adhhamofficial

After upgrading to version 0.6.0 I hit the same issue:(( I am using Windows 11 and standard Terminal

✕ [API Error: Unexpected line format in response: ,]

/about gives me

│ │ │ About Gemini CLI │ │ │ │ CLI Version 0.6.0 │ │ Git Commit 7e1bce72 │ │ Model gemini-2.5-pro │ │ Sandbox no sandbox │ │ OS win32 │ │ Auth Method OAuth │ │

 Debug Console (ctrl+o to close)                                                                           │
│                                                                                                           │
│ ℹ File C:\Users\xxx\.cache/vscode-ripgrep/ripgrep-v13.0.0-10-x86_64-pc-windows-msvc.zip has  │
│    been cached                                                                                            │
│ ℹ Authenticated via "oauth-personal".                                                                    │
│ ✖ Error when talking to Gemini API Full report available at:                                             │
│    C:\Users\xxx\AppData\Local\Temp\gemini-client-error-Turn.run-sendMessageStream-2025-09-24T14-2 │
│    8-16-196Z.json    

and the report with sensitive data removed.

{
  "error": {
    "message": "Unexpected line format in response: ,",
    "stack": "Error: Unexpected line format in response: ,\n    at file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/server.js:128:27\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/server.js:27:30\n    at async LoggingContentGenerator.loggingStreamWrapper (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/loggingContentGenerator.js:70:30)\n    at async GeminiChat.stopBeforeSecondMutator (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:484:26)\n    at async GeminiChat.processStreamResponse (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:374:26)\n    at async file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:212:42\n    at async Turn.run (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/turn.js:59:30)\n    at async GeminiClient.sendMessageStream (file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/client.js:390:26)\n    at async file:///C:/Users/xxx/AppData/Roaming/npm/node_modules/@google/gemini-cli/dist/src/ui/hooks/useGeminiStream.js:402:26"
  },
  "context": [
    {
      "role": "user",
      "parts": [
        {
          "text": "This is the Gemini CLI. We are setting up the context for our chat.\nToday's date is Wednesday, 24 September 2025 (formatted according to the user's locale).\nMy operating system is: win32\nI'm currently working in the directory: C:\\dev\\projects\\xxx\nHere is the folder structure of the current working directories:\n\nShowing up to 200 items (files + folders). Folders or files indicated with ... contain more items not shown, were ignored, or the display limit (200 items) was reached.\n\nC:\\dev\\projects\\xxx\\\n├───.gitignore\n├───bitbucket-pipelines.yml\n├───Dockerfile\n├───pom.xml\n├───settings.xml\n├───.git\\...\n├───.idea\\\n│   └───dataSources\\...\n├───logs\\\n├───src\\\n│   ├───db\\\n│   │  ..."
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "text": "Got it. Thanks for the context!"
        }
      ]
    },
    {
      "role": "user",
      "parts": [
        {
          "text": "Can you migrate @src/main/java/com/xxx/app/integration/jira/SearchClient.java to use new v3 api                                    ││    (https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get) ie. use page tokens"
        },
        {
          "text": "\n--- Content from referenced files ---"
        },
        {
          "text": "\nContent from @C:\\dev\\projects\\xxx\\src\\main\\java\\com\\xxx\\app\\integration\\jira\\SearchClient.java:\n"
        },
        {
          "text": "file content..."
        },
        {
          "text": "\n--- End of content ---"
        }
      ]
    },
    [
      {
        "text": "Can you migrate @src/main/java/com/xxx/app/integration/jira/SearchClient.java to use new v3 api                                    ││    (https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get) ie. use page tokens"
      },
      {
        "text": "\n--- Content from referenced files ---"
      },
      {
        "text": "\nContent from @C:\\dev\\projects\\xxx\\src\\main\\java\\com\\xxx\\app\\integration\\jira\\SearchClient.java:\n"
      },
      {
        "text": "file content..."
      },
      {
        "text": "\n--- End of content ---"
      }
    ]
  ]
}

I tried to reinstalling gemini cli, and reauthenticating (using oath). I also asked some stupid questions like what's the capital of UK and model responded correctly.

pbartoszek avatar Sep 24 '25 14:09 pbartoszek

I am having the same issue running Gemini CLI 0.6.1 on macOS 15.6.1

emilianomoscato avatar Sep 25 '25 14:09 emilianomoscato

It's working again for me but now from time to time I get ✕ [API Error: Model stream ended with an invalid chunk or missing finish reason.]

pbartoszek avatar Oct 01 '25 10:10 pbartoszek

I have the same issue with EVERY prompt I try - what a piece of garbage - google, are you interested in fixing this bug or what? I am using 0.7.0 on MacOS 15.6 - authentication via oauth. Here's the error:

{ "error": { "message": "Unexpected line format in response: ,", "stack": "Error: Unexpected line format in response: ,\n at file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/server.js:128:27\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/server.js:27:30\n at async LoggingContentGenerator.loggingStreamWrapper (file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/loggingContentGenerator.js:70:30)\n at async GeminiChat.stopBeforeSecondMutator (file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:480:26)\n at async GeminiChat.processStreamResponse (file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:374:26)\n at async file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:215:42\n at async Turn.run (file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/turn.js:59:30)\n at async GeminiClient.sendMessageStream (file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/client.js:405:26)\n at async file:///Users/shanna.murry/.nodenv/versions/20.19.3/lib/node_modules/@google/gemini-cli/dist/src/ui/hooks/useGeminiStream.js:401:26" },

shannamurry avatar Oct 03 '25 14:10 shannamurry

@allenhutchison you marked 3 threads as duplicates, and at this point SCORES of people have reported this issue, will this ever be addressed by the Gemini CLI team, or are these just going to be reported ad infinitum with zero response?

jazir555 avatar Oct 14 '25 23:10 jazir555

Same issue

ajaymalik14 avatar Oct 15 '25 15:10 ajaymalik14

@jazir555 I appreciate your frustration. Part of our triage process is to consolidate duplicates down to a single issue so that we can make prioritization decisions for the core team. We are actively trying to fix quality of life and product issues over the last few weeks and as a part of that are working very hard to make sure the product is stable and works correctly. This particular issue seems to be pretty tricky to fix, and involves a lot of moving parts between our application and the model api.

allenhutchison avatar Oct 15 '25 18:10 allenhutchison

@jazir555 I appreciate your frustration. Part of our triage process is to consolidate duplicates down to a single issue so that we can make prioritization decisions for the core team. We are actively trying to fix quality of life and product issues over the last few weeks and as a part of that are working very hard to make sure the product is stable and works correctly. This particular issue seems to be pretty tricky to fix, and involves a lot of moving parts between our application and the model api.

Thanks for getting back to me. The API errors are much more widespread than this, I think I've had at least 6 different unique error codes that are API based, I had opened issues for all the ones I encountered.

jazir555 avatar Oct 16 '25 04:10 jazir555

Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.

It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.

Thank you for your contribution!

gemini-cli[bot] avatar Dec 03 '25 21:12 gemini-cli[bot]

So to confirm, you aren't actually going to fix the API errors then? You'll just let these be issues permanently? @kklashtorny1

jazir555 avatar Dec 04 '25 00:12 jazir555

So to confirm, you aren't actually going to fix the API errors then? You'll just let these be issues permanently? @kklashtorny1

Hi @jazir555, could you please confirm if you are still experiencing this issue and provide updated Gemini CLI configuration details?

ghost avatar Dec 04 '25 14:12 ghost