Skip to content

test(session): regression test for #26574 + mirror loosening on Vcs.FileDiff#26578

Merged
kitlangton merged 1 commit intodevfrom
kit/26574-followup-vcs-and-tests
May 9, 2026
Merged

test(session): regression test for #26574 + mirror loosening on Vcs.FileDiff#26578
kitlangton merged 1 commit intodevfrom
kit/26574-followup-vcs-and-tests

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Follow-up to #26574 (already merged).

What this adds

  1. Regression test (packages/opencode/test/server/session-diff-missing-patch.test.ts). fix(sessions): allow optional patch field in diff for migrated sessions #26574 shipped without a test; this exercises the actual bug shape:

    • Create a session
    • Write a session_diff storage entry with no patch field (mimics legacy/imported on-disk shape)
    • Call `GET /session//diff`
    • Pre-fix the typed response encoder rejects → 400 → desktop session load fails
    • Post-fix the response is 200 with `patch: undefined` in the entry

    Verified red → green → red → green locally before pushing.

  2. Mirror schema loosening on `Vcs.FileDiff` (packages/opencode/src/project/vcs.ts:231). Same shape (`file/patch/additions/deletions/status`), used by /instance/vcs/diff. Current producer always sets `patch`, but loosening matches `Snapshot.FileDiff` so any future producer that omits patch can't reintroduce the same crash on the sibling endpoint.

  3. Comment on `Snapshot.FileDiff.patch` explaining why it's optional, so the next reader doesn't tighten it back.

Why this matters

Same disease family as #26546, #26553, #26566, #26572: post-Hono-migration strict Schema validation rejects legitimate-looking on-disk data, the response 4xx's, and the client crashes (or is told nothing useful). The original PR fixed the symptom on one endpoint without nailing it down with a test or extending the fix to the sibling.

Test

…leDiff

- Adds a regression test that exercises the actual bug shape: a
  legacy/imported `session_diff` storage entry without a `patch`
  field. Pre-#26574 the typed encoder rejected the response and
  /session/<id>/diff returned 400. Test verifies red->green->red.
- Mirrors the schema loosening on Vcs.FileDiff so any future
  /instance/vcs/diff producer that omits patch can't crash the
  same way.
- Adds a comment on Snapshot.FileDiff.patch explaining why it's
  optional.
@kitlangton kitlangton enabled auto-merge (squash) May 9, 2026 20:27
@kitlangton kitlangton disabled auto-merge May 9, 2026 20:30
@kitlangton kitlangton merged commit 805af01 into dev May 9, 2026
11 checks passed
@kitlangton kitlangton deleted the kit/26574-followup-vcs-and-tests branch May 9, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant