Skip to content

fix(modify):stop modified array item fields being added to schema when missing in original schema#250

Merged
danielcardoso5 merged 4 commits intomainfrom
fix-unexisting_modified_array_item_fields_added_to_schema
Mar 5, 2026
Merged

fix(modify):stop modified array item fields being added to schema when missing in original schema#250
danielcardoso5 merged 4 commits intomainfrom
fix-unexisting_modified_array_item_fields_added_to_schema

Conversation

@remotecom
Copy link
Collaborator

@remotecom remotecom commented Feb 26, 2026

Pull Request

Summary

Stop merging fields..items into the schema when the target doesn’t exist. Item-level changes are applied only to existing array item schemas and only to existing properties, so conditionally omitted fields are no longer added. Adding new structure remains the responsibility of consumers (e.g. via the create property).

Changes Made

  • src/modify-schema.ts

    • No blind merge of items: items is removed from the object that gets merged into the field, so it's never merged in as a top-level attribute.
    • Item changes only when structure exists: When fieldChanges.items is set, the code only applies it when fieldAttrs.items is a single existing item schema (object, not tuple). It then merges item-level attributes and runs rewriteFields for items.properties on that existing item schema, so only existing item properties are modified; properties that don't exist in the original schema are not added.
  • test/modify-schema.test.ts

    • New test that adding a property under fields.<arrayPath>.items.properties that doesn't exist in the original item schema does not add it to the final schema.

Related Issues/PRs

None.

Screenshots (Before/After if applicable)

N/A.

Checklist


Note

Medium Risk
Changes core modifySchema merge behavior for array items, which could alter existing customizations that relied on the previous (more permissive) merge semantics. Scope is limited and covered by new tests, but it affects schema mutation logic used across consumers.

Overview
Fixes modifySchema so config.fields.<arrayPath>.items is no longer blindly merged into the field schema, preventing accidental addition of new items structure/properties when they weren’t present in the original schema.

Adds targeted handling to apply items mutations only when the array has an existing single item schema object, and to rewrite items.properties using the same “modify-only-if-exists” behavior. New unit tests cover updating existing array item properties and ensuring missing item properties are ignored rather than created.

Written by Cursor Bugbot for commit f47e576. This will update automatically on new commits. Configure here.

- Stop merging fields.<arrayPath>.items into the field when target may not exist
- Apply item-level changes only when fieldAttrs.items is a single item schema
- Only rewrite existing item properties; use create for new structure
- Add test that existing array item properties can be modified

Made-with: Cursor
danielcardoso5
danielcardoso5 previously approved these changes Mar 2, 2026
Copy link
Collaborator

@danielcardoso5 danielcardoso5 left a comment

Choose a reason for hiding this comment

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

Just two nits, approving, but can approve again once updated!

@ricardojoaomestre
Copy link
Contributor

@danielcardoso5 I've addressed your comments. We're good to go 👍

@danielcardoso5 danielcardoso5 merged commit 85e694d into main Mar 5, 2026
5 checks passed
@danielcardoso5 danielcardoso5 deleted the fix-unexisting_modified_array_item_fields_added_to_schema branch March 5, 2026 11:18
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.

4 participants