Skip to content

Copilot returned invalid JSON for commit message generation #22958

Closed

Description

@frankyuan

The problem

Image Auto generate commit messge gots this error.

Release version

Version 3.6.6 (x64)

Operating system

Window 11

Steps to reproduce the behavior

No response

Log files

No response

Screenshots

No response

Additional context

No response

Activity

  1. desktop-triage commented on Oct 2, 2026

    @desktop-triage

    Triage summary: This looks like a genuine bug report rather than a duplicate — it's a distinct symptom (strict JSON-parse failure surfaced as an error dialog) from the recently-fixed #22815 (co-author trailer leakage, closed via #22948). I'm suggesting bug and copilot labels, plus more-info-needed since no logs, reproduction steps, or the actual raw Copilot response text were included, which are needed to confirm the root cause.

    Initial hypothesis: Commit message generation parses the Copilot model's raw text response with a strict JSON parser in parseCopilotCommitMessage. It first tries to extract a fenced ```json or ``` block via regex, falling back to using the whole trimmed response if no fence is found, then calls JSON.parse on that string and throws "Copilot returned invalid JSON for commit message generation" on any parse failure — matching the exact error text in the reporter's screenshot. Although the system prompt (CommitMessageSystemPrompt in copilot-store.ts) instructs the model to return a raw JSON object with no markdown wrapper, there's no guarantee the model always complies: it could add prose before/after the JSON, use smart quotes, emit unescaped control characters inside string values, or get truncated mid-response (e.g. by a response-size/token limit), any of which would make the parser's regex fail to find a clean match and then fail JSON.parse on whatever remains. Confirming which of these occurred requires the actual raw Copilot response text and/or application log entries from the time of failure, neither of which were attached to this report.

    Duplicate check: No duplicate found. #22815 ("intermittently appends extra description and adds Copilot as official co-author") was a different, already-fixed issue — that case produced a successfully-parsed but unwanted co-author trailer, not a parse failure.

    To help confirm the cause, it would help to have the application log file from the session where this occurred (Desktop writes these under the app's logs folder) and, if possible, the diff size/content that triggered the generation.

    Generated by Issue Triage (skills-driven) for #22958 · auto · 52.1 AIC · ⌖ 1.27 AIC · ⊞ 8.9K · ◷

  2. frankyuan commented on Oct 2, 2026

    @frankyuan
    Author

    The log is in below:

    2026-10-02T03:10:57.825Z - warn: [ui] CopilotStore: Failed to generate commit message
    Error: Copilot returned invalid JSON for commit message generation
    at Ls (C:\Users*\AppData\Local\GitHubDesktop\app-3.6.6\webpack:\app\src\lib\copilot-commit-message.ts:23:11)
    at my.generateCommitMessage (C:\Users*
    \AppData\Local\GitHubDesktop\app-3.6.6\webpack:\app\src\lib\stores\copilot-store.ts:1143:14)
    at C:\Users*\AppData\Local\GitHubDesktop\app-3.6.6\webpack:\app\src\lib\stores\app-store.ts:6393:66
    at fy.withIsGeneratingCommitMessage (C:\Users*
    \AppData\Local\GitHubDesktop\app-3.6.6\webpack:\app\src\lib\stores\app-store.ts:5412:7)
    2026-10-02T03:11:21.497Z - warn: [ui] CopilotStore: Failed to generate commit message
    Error: Copilot returned invalid JSON for commit message generation
    at Ls (C:\Users*\AppData\Local\GitHubDesktop\app-3.6.6\webpack:\app\src\lib\copilot-commit-message.ts:23:11)
    at my.generateCommitMessage (C:\Users*
    \AppData\Local\GitHubDesktop\app-3.6.6\webpack:\app\src\lib\stores\copilot-store.ts:1143:14)
    at C:\Users*\AppData\Local\GitHubDesktop\app-3.6.6\webpack:\app\src\lib\stores\app-store.ts:6393:66
    at fy.withIsGeneratingCommitMessage (C:\Users*
    \AppData\Local\GitHubDesktop\app-3.6.6\webpack:\app\src\lib\stores\app-store.ts:5412:7)

  3. babakks commented on Oct 6, 2026

    @babakks
    Member

    I can't reproduce this locally, @frankyuan. Thanks for providing the log! 🙏

    This seems like an edge case that may be difficult to isolate, so I need a few more details to see if we can make progress:

    1. Does retrying successfully generate a commit message, or does every attempt fail?
    2. Approximately how long does generation take before the error appears?
    3. Does this happen in every repository or only this repository?
    4. Was there anything notable about the staged files, such as large blobs, a large number of files, unusually large diffs, binary files, or generated content?
    5. Do the same staged changes fail consistently, or was this a one time occurrence?

    Anything else specific to the staged changes or repository that might help us reproduce the failure would also be useful.

  4. added
    more-info-needed
    on Oct 6, 2026
  5. github-actions commented on Oct 6, 2026

    @github-actions
    Contributor

    Thank you for your issue! Unfortunately, we are unable to reproduce the issue you are experiencing. Please provide more information so we can help you.

    Here are some tips for writing reproduction steps:

    • Step by step instructions accompanied by screenshots or screencasts are the best.
    • Be as specific as possible; include as much detail as you can.
    • If not already provided, include:
      • the version of the application you are using.
      • the operating system you are using
      • any environment factors you can think of.
      • any custom configuration you are using.
      • a log file from the day you experienced the issue (access log files via Help > Show Logs in Finder/Explorer).
    • If relevant and can be shared, provide the repository or code you are using.
  6. frankyuan commented on Oct 7, 2026

    @frankyuan
    Author

    This error isn’t persistent; it happens randomly. Seems like the LLM returns not a valid JSON object. I'm using auto model for commit message generation.

    Does retrying successfully generate a commit message, or does every attempt fail?

    • Randomly, sometime retry worked, but sometimes still fail.

    Approximately how long does generation take before the error appears?

    • 5 ~ 10 seconds.

    Does this happen in every repository or only this repository?

    • every repository

    Was there anything notable about the staged files, such as large blobs, a large number of files, unusually large diffs, binary files, or generated content?

    • multiple file changes, but not large blob.

    Do the same staged changes fail consistently, or was this a one time occurrence?

    • Randomly.
  7. removed
    more-info-needed
    on Oct 7, 2026
  8. sergiou87 commented on Oct 14, 2026

    @sergiou87
    Member

    Could you try 3.6.7? It has a newer version of Copilot SDK inside which improves the auto model experience 🤞

  9. added
    more-info-needed
    on Oct 14, 2026
  10. ElCanu commented on Oct 16, 2026

    @ElCanu

    I still have the same bug wih 3.6.7.. its rng but now i cant get pass this error somehow,..

  11. ElCanu commented on Oct 16, 2026

    @ElCanu

    It does that on Auto, switched to Grok 4.7 and my commits message generation are working now

  12. ElCanu commented on Oct 16, 2026

    @ElCanu

    I built a local OpenAI-compatible bridge on 127.0.0.1 that forwards GitHub Desktop’s chat request to the Cursor API. API key and model id (including Auto) come from the Desktop provider settings. Same UI, different backend.

    I hit the same “Copilot returned invalid JSON for commit message generation” error. That was not an Auto vs Grok thing on my side. Desktop JSON.parses choices[0].message.content and expects:

    {"title":"...","description":"..."}

    The bridge was returning a plain one-line subject. Once the assistant text is always that JSON object (and a single line from the model is mapped into title with an empty description if needed), generation works, Auto included.

    Canceled Copilot anyway. I did not want to keep paying for commit messages while wiring my own fix around the response format.

  13. github-actions commented on Oct 28, 2026

    @github-actions
    Contributor

    Thank you for your issue!
    We haven't gotten a response to our questions above. With only the information that is currently in the issue, we don't have enough information to take action. We're going to close this but don't hesitate to reach out if you have or find the answers we need. If you answer our questions above, this issue will automatically reopen.

  14. github-actions commented on Nov 11, 2026

    @github-actions
    Contributor

    Thank you for your issue!
    We haven't gotten a response to our questions above. With only the information that is currently in the issue, we don't have enough information to take action. We're going to close this but don't hesitate to reach out if you have or find the answers we need. If you answer our questions above, this issue will automatically reopen.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    more-info-neededneeds-triageunable-to-reproduce

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions