Skip to content

Inherit the framed flag on derived versioned value schemas - #109

Open
moromisato wants to merge 1 commit into
holepunchto:mainfrom
moromisato:fix/versioned-value-inherits-framed
Open

moromisato wants to merge 1 commit into
holepunchto:mainfrom
moromisato:fix/versioned-value-inherits-framed

Conversation

@moromisato

Copy link
Copy Markdown

When a collection's schema is a versioned type, the builder derives a per-version value schema so stored values keep their version dispatch. That derived type gets registered without a framed flag, so hyperschema falls back to its default (framed) no matter what the source type said.

The effect: a versioned schema declared framed: false still writes framed (length-prefixed) values on disk. Readers built before framing existed then fail to decode them with Out of bounds. I hit this keeping a store readable by older released peers after upgrading to a hyperschema that frames versioned records.

The fix is one line — pass the source schema's framed through to the derived type:

this.builder.schema.register({
  derived: true,
  framed: schema.framed,
  namespace: schema.namespace,
  name: schema.name + type,
  versions
})

I added a test to test/versions.js that builds one versioned collection with the default (framed) and one with framed: false, and checks the generated messages.js: the default frames its value, framed: false does not. It fails on main and passes with the change. Full suite stays green (139/139).

When a collection's schema is a versioned type, the builder derives a
per-version value schema so stored values keep their version dispatch. That
derived type was registered without a framed flag, so it always fell back to
the default (framed) regardless of the source type.

A versioned schema declared `framed: false` therefore still wrote framed
values on disk, which readers built before framing existed cannot decode.

Pass the source schema's framed flag through to the derived type, and add a
test that a `framed: false` versioned collection value stays unframed.
@moromisato
moromisato requested a review from a team September 21, 2026 19:48

This branch has not been deployed

No deployments
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.

2 participants