Skip to content

[AI-assisted] Desktop reload fails with Expected JSON value for nested apply_patch metadata #38617

Closed as not planned

Description

@su-351917

AI-authorship disclosure

This issue was researched and drafted by an AI coding assistant, then submitted under the account owner's direction. The observed symptom was supplied by the human reporter. The source-code findings are linked below; the affected local database has not yet been inspected, and all hypotheses are explicitly marked as such.

Summary

OpenCode Desktop shows the following error whenever it reloads a project/session:

Expected JSON value, got [[{"filePath":...,"type":"update","patch":"Index: ..."}]]

The workload continues to run and files continue to update. The failure is observed specifically during Desktop project/session reload.

Environment

  • Client: OpenCode Desktop
  • Workload: large, long-lived sessions; multiple sessions used for the same project
  • Exact Desktop version, OS/arch, active plugins/MCP configuration: to be added

Observed behavior

  • Reopening/reloading the same project reproduces the error.
  • The payload resembles patch history.
  • Its leading [[{ suggests a nested array.
  • The visible object has filePath, type: "update", and a string patch beginning with Index: ....
  • Current work is not stopped: tool execution and file writes continue.

Source investigation

Confirmed

Hypothesis, not yet verified against the affected DB

A historical tool part, likely tool.state.metadata.files, may contain Patch[][] / FileChange[][] rather than the flat FileChange[] written by the current apply_patch tool. Reload then reaches an HTTP response JSON/schema boundary that rejects the persisted value.

This is not yet evidence that snapshot PatchPart itself is nested. The source has no declared Patch[][] in the snapshot/revert path.

Related reports

Expected behavior

A malformed or legacy persisted tool part must not prevent a whole session/project from reloading. At minimum, the response should identify the failing part.id and safely isolate or omit that part rather than failing session message retrieval.

Requested guidance

  1. Is there a known migration/schema incompatibility for legacy apply_patch metadata or Patch[][]?
  2. What is the supported non-destructive recovery path for one malformed session part?
  3. Is snapshot: false expected only to prevent future snapshot generation, rather than repair existing persisted metadata?
  4. Is there a recommended export/query that maintainers want attached to identify the exact bad row?

I can attach a sanitized session export, relevant part/session_message query results, and a Desktop debug-log archive after guidance on the preferred redaction format.

Activity

  1. changed the title [-]Desktop reload fails with Expected JSON value for nested apply_patch metadata[/-] [+][AI-assisted] Desktop reload fails with Expected JSON value for nested apply_patch metadata[/+] on Jul 24, 2026
  2. github-actions commented on Jul 24, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The issue was drafted by an AI assistant (explicitly disclosed in the "AI-authorship disclosure" section). Long, AI-generated descriptions are not acceptable per our contributing guidelines. Please rewrite this in your own words, summarizing only what you actually observed: the error message, when it occurs, and your environment details.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. su-351917 commented on Jul 24, 2026

    @su-351917
    Author

    Closing after further local investigation. A verified SQLite backup and read-only scan found no nested Patch[][] values and no malformed persisted rows covered by #29908. The matching server-log failures instead appear closer to #37650/#37679: apply_patch live metadata contains an optional movePath nested under metadata.files[], which may be undefined before JSON persistence removes it. I will add the factual reproduction evidence to the existing related report rather than continue this non-compliant duplicate issue.

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

Metadata

Metadata

Assignees

Labels

needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions