Skip to content

fix: modify() preserve unknown top-level schema keys when using pick#264

Merged
sandrina-p merged 2 commits into
mainfrom
rmt-2524-jsf-modify-loses-extra-keys-like-x-meta
Jul 10, 2026
Merged

fix: modify() preserve unknown top-level schema keys when using pick#264
sandrina-p merged 2 commits into
mainfrom
rmt-2524-jsf-modify-loses-extra-keys-like-x-meta

Conversation

@sandrina-p

@sandrina-p sandrina-p commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Bug

This bug happens in v1, but not in v0.

modify() used with pick silently drops any top-level schema key it doesn't explicitly know about (type, x-rmt-meta, additionalProperties, $schema, etc). Only properties, x-jsf-order, required, allOf, x-jsf-logic survived.

Repro:

const schema = {
  'type': 'object',
  'x-rmt-meta': { jsfOldVersion: true },
  'properties': {
    name: { type: 'string' },
    age: { type: 'number' },
  },
}

const { schema: result } = modify(schema, { pick: ['name'] })

result.type // undefined, should be 'object'
result['x-rmt-meta'] // undefined, should be { jsfOldVersion: true }

Fix

Added the missing default case so unrecognized top-level keys pass through unchanged, matching v0.

pickFields() only copied properties/x-jsf-order/required/allOf/x-jsf-logic,
silently dropping anything else (type, x-rmt-meta, additionalProperties...).
Add a default case so unrecognized keys pass through, matching v0 behavior.
@sandrina-p sandrina-p self-assigned this Jul 10, 2026
@sandrina-p sandrina-p changed the title fix: modify() with pick drops unknown top-level schema keys fix: modify() preserve unknown top-level schema keys when using pick Jul 10, 2026

@nitin-remote nitin-remote left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, thank you!

@sandrina-p sandrina-p merged commit 682a03c into main Jul 10, 2026
5 checks passed
@sandrina-p sandrina-p deleted the rmt-2524-jsf-modify-loses-extra-keys-like-x-meta branch July 10, 2026 09:14
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