Skip to content

Fix: build sanitise schema per item to restore subclass dispatch (fixes #100)#101

Open
taylortom wants to merge 1 commit intomasterfrom
fix/per-item-sanitise-schema
Open

Fix: build sanitise schema per item to restore subclass dispatch (fixes #100)#101
taylortom wants to merge 1 commit intomasterfrom
fix/per-item-sanitise-schema

Conversation

@taylortom
Copy link
Copy Markdown
Collaborator

@taylortom taylortom commented Apr 30, 2026

Fixes #100

Fix

  • Restore per-item getSchema dispatch in sanitise() so subclasses overriding getSchema on data (notably ContentModule) get the right schema per item; previously the array was passed as data, falling back to the base content schema and stripping component-specific / extension fields from GET responses.

PR #97 hoisted the getSchema call out of the per-item loop on the
basis that getSchema is idempotent for a given schemaName. That holds
for the base implementation here but not for subclasses that override
getSchema to dispatch on the item itself (notably ContentModule, which
returns a different schema per content type / component / enabled-
plugin set).

With the hoisted call, ContentModule's getSchema received the array as
its data argument, fell back to the base content schema, and dropped
all component-specific and extension fields when sanitising GET
responses. Restoring per-item getSchema fixes the dispatch.

The cost is bounded by DataCache (find/findOne) and ContentModule's
own _schemaCache, which between them keep extra DB hits to one per
unique component type per request.
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.

build sanitise schema per item to restore subclass dispatch

1 participant