Fix forest codec version validation in schema#26395
Fix forest codec version validation in schema#26395CraigMacomber merged 4 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
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
UsageErrormessages 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. |
packages/dds/tree/src/test/feature-libraries/forest-summary/forestSummarizerCodec.spec.ts
Outdated
Show resolved
Hide resolved
packages/dds/tree/src/test/feature-libraries/forest-summary/forestSummarizerCodec.spec.ts
Outdated
Show resolved
Hide resolved
…restSummarizerCodec.spec.ts
|
|
||
| import { FormatCommon, ForestFormatVersion } from "./formatCommon.js"; | ||
|
|
||
| export const FormatV1 = FormatCommon(brand<ForestFormatVersion>(ForestFormatVersion.v1)); |
There was a problem hiding this comment.
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: [ |
There was a problem hiding this comment.
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
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.