Skip to content

fix: a format version that is not a whole number, or is lower, is refused for what it is - #54

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
fix/50-format-version-message
Nov 12, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
fix/50-format-version-message

Conversation

@CaffeinatedCoder

@CaffeinatedCoder CaffeinatedCoder commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Closes #50

Problem

DeclarationCodec.Read refuses a stored declaration whose format version v is not the one it reads. Two of those refusals said the wrong thing:

  1. "v":"2" (or true, null, an array) threw System.Text.Json's own message, "The requested operation requires an element of type 'Number', but the target element has type 'String'", with no annotation key in it. TryGetInt32 was called before the element's kind was checked.
  2. A v below 2 was told the snapshot "was written by a newer SchemaKit … Update the package", which is wrong advice for an older format.

Nothing was read wrongly: both were refused before and are refused now.

Change

  • Declarations/Internal/DeclarationCodec.cs: the element's kind is checked before TryGetInt32.
  • Infrastructure/Internal/SchemaKitStrings.cs: UnknownFormatVersion keeps its first sentence and ends in one of three: not a whole number (edited or damaged), written by a newer SchemaKit (update), or an older format this version does not read.

Tests

Kernel tests without a server: 263 before, 271 after. The PostgreSQL integration tests did not run locally; CI runs them.

A_format_version_this_version_does_not_know_is_refused now has 11 rows: 3, 1, 0, -1, missing, "2", 2.5, true, null, [2] and a number too large for an int. Each asserts the key, the stored version and the reason, and that only 3 is told "newer" and "Update the package".

Undone Fails
The kind check before TryGetInt32 the rows "2", true, null, [2]
A lower version told "newer" the rows 1, 0, -1

🤖 Generated with Claude Code

…used for what it is

Closes #50.

`"v":"2"` was refused by System.Text.Json's own message, which names no
annotation, because TryGetInt32 was asked before the element's kind. And a
version below the one this package reads was said to come from a newer
SchemaKit, with the advice to update.

Both were refused before and are refused now; only what they are told
changes. Only a higher version says "newer" and "Update the package".

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 11, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) severity/low Cosmetic, message or documentation-level difference area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 11, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 9f1b9f3 into main Nov 12, 2026
8 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/50-format-version-message branch November 12, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring bug Something isn't working package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) severity/low Cosmetic, message or documentation-level difference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The refusal of a format version says the wrong thing for a version that is not a number, and for an older one

1 participant