Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(contracts): decode growing config unions forward-compatibly #5055

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/5055/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

What Changed

  • Added ForwardCompatibleArray to contracts: a wire codec for server→client arrays whose element unions grow over time. Decoding drops elements the current build cannot decode instead of failing the whole payload; encoding is the plain array encoding, byte-identical to before.
  • Applied it to the three growing sets in the config payloads: resolved keybindings (ResolvedKeybindingsConfig), server config issues (ServerConfigIssues), and availableEditors.
  • Authoring/upsert inputs (KeybindingRule, ServerUpsertKeybindingInput) stay strict — clients only create bindings for commands they know.

Why

Nightly 0.0.32-nightly.20260730.957 added filePicker.toggle / projectSearch.toggle, and 0.0.31 clients rejected the entire serverGetConfig response during connect (the session's ready gate awaits initialConfig, so a config decode failure means the client never reaches the connected state). The root cause is that clients validate server-owned, growing literal unions as closed sets.

#5018 worked around this with per-connection command-set version negotiation and server-side filtering. That treats the symptom: every future command addition would require a version bump plus a new filter branch on the WS hot path, and the same break class remained for issue kinds, editor ids, and when-node types. This PR fixes the class instead: clients tolerate unknown members by dropping them. This is safe because every dispatch site matches commands by string equality (an unknown command is already an inert no-op), and the settings UI renders any command string.

Old servers are unaffected (encoded output is unchanged). Already-shipped 0.0.31 clients still need a new store build to pick this up — this intentionally replaces the OTA/negotiation hotpatch.

Verification

  • New contracts tests: unknown commands / unknown when-node types / malformed entries dropped, known rules preserved in order, encode round-trip unchanged; unknown issue kinds and editor ids dropped.
  • New client-runtime session test: a mock newer server sends a config containing an unknown command, unknown issue kind, and unknown editor id over the raw wire — the session reaches ready and exposes only the known subset (this is the exact incident scenario).
  • vp test run packages/contracts packages/client-runtime apps/server/src/server.test.ts apps/server/src/keybindings.test.ts packages/shared — all passing (1000+ tests)
  • vp run --filter @t3tools/contracts --filter @t3tools/client-runtime --filter t3 --filter @t3tools/shared --filter web --filter mobile typecheck — clean
  • Targeted lint + format checks for all changed files

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I added regression coverage

🤖 Generated with Claude Code


Note

Medium Risk Changes wire decoding for core connect-time ServerConfig fields; behavior is intentionally permissive (drop unknowns) but affects every client session bootstrap path.

Overview Older clients were failing the entire serverGetConfig decode when a newer server sent unknown keybinding commands, issue kinds, or editor IDs—blocking the session ready gate. This PR introduces ForwardCompatibleArray, which filters out array elements the current schema cannot decode instead of rejecting the whole payload; wire encoding stays unchanged.

That codec is applied to ResolvedKeybindingsConfig, ServerConfigIssues, and availableEditors on server→client config paths. Client authoring inputs (KeybindingRule, upsert payloads) remain strict.

Regression tests cover per-element dropping (unknown commands, when node types, malformed entries), encode round-trips, and a client-runtime session test where a mock newer server still reaches ready with only the known subset.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c0b2abc90b6f47087b5c09bb4123c7f838165b67. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Decode growing config unions forward-compatibly by dropping unknown entries

  • Introduces ForwardCompatibleArray in baseSchemas.ts, which decodes arrays by silently dropping elements that fail to decode rather than failing the entire array.
  • Applies ForwardCompatibleArray to ResolvedKeybindingsConfig, ServerConfigIssues, and ServerConfig.availableEditors so that unknown commands, issue kinds, or editor IDs from a newer server are dropped instead of breaking the config decode.
  • Behavioral Change: previously, a single unrecognized entry in these arrays would cause the entire decode to fail; now such entries are silently filtered out.
Macroscope summarized c0b2abc.
    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 0db506c1-7341-418a-8f72-da17e1e8aa12

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Approvability

      Verdict: Approved c0b2abc

      This is a defensive forward-compatibility fix that makes schema decoding more resilient by dropping unrecognized union variants instead of failing entirely. Changes are self-contained to schema definitions with comprehensive test coverage.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge merged thisdf78cda

    5. juliusmarminge closed this

Sign in to join this conversation.