Skip to content

Fix forest codec version validation in schema#26395

Merged
CraigMacomber merged 4 commits intomicrosoft:mainfrom
CraigMacomber:FixForestCodecVersioning
Feb 10, 2026
Merged

Fix forest codec version validation in schema#26395
CraigMacomber merged 4 commits intomicrosoft:mainfrom
CraigMacomber:FixForestCodecVersioning

Conversation

@CraigMacomber
Copy link
Copy Markdown
Contributor

Description

Fixes the same bug that was fixed in #26372, except this time for the forest codec.

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber requested a review from a team as a code owner February 10, 2026 18:46
Copilot AI review requested due to automatic review settings February 10, 2026 18:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes version validation for the forest summarizer codec so that decoding data written in any supported forest format version fails with a UsageError for unsupported versions (instead of failing schema validation early due to a write-version-specific schema), matching the behavior previously fixed for the field batch codec.

Changes:

  • Update forest codec schema validation to accept all supported forest format versions (v1 + v2) during decoding.
  • Refactor/expand tests to exercise cross-version decode behavior and to validate proper UsageError messages for invalid versions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/dds/tree/src/feature-libraries/forest-summary/codec.ts Switches schema validation to a v1/v2 union so supported-version checks run before per-version schema validation.
packages/dds/tree/src/test/feature-libraries/forest-summary/forestSummarizerCodec.spec.ts Consolidates valid encode/decode cases across codecs and updates invalid-version tests to assert UsageError behavior.


import { FormatCommon, ForestFormatVersion } from "./formatCommon.js";

export const FormatV1 = FormatCommon(brand<ForestFormatVersion>(ForestFormatVersion.v1));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branding removed type safety, since ForestFormatVersion.v1 is a branded constant, and this removed the constant from the typing.

* which coded version is expected to encode to this exact data (if any)
* ][]
*/
const validData: [
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All data, old and new, should be able to be decoded regardless of minVersionForCollab, so the test suites have been combined. The version is kept to know which version of the coded should exactly match the expected data

@CraigMacomber CraigMacomber changed the title Fix forest coded version validation in schema Fix forest codec version validation in schema Feb 10, 2026
@CraigMacomber CraigMacomber merged commit 85c8127 into microsoft:main Feb 10, 2026
32 checks passed
@CraigMacomber CraigMacomber deleted the FixForestCodecVersioning branch February 10, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants