Skip to content

Validate only the submitted fields on update - #107

Open
ramonski wants to merge 1 commit into
feature/fix-single-valued-uidreferencefrom
feature/partial-update-validation
Open

Validate only the submitted fields on update#107
ramonski wants to merge 1 commit into
feature/fix-single-valued-uidreferencefrom
feature/partial-update-validation

Conversation

@ramonski

@ramonski ramonski commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description of the issue/feature this PR addresses

update_object_with_data re-validates the whole object after applying the record. The field managers already validate each submitted field on set, so this second pass only re-checks fields the caller never touched, and it fails when one of them no longer passes a full validation: an Archetypes field holding a stored legacy value, or a Dexterity behavior invariant such as IExcludeFromNavigationDefault. In practice this blocks partial updates to setup objects (for example toggling a single bika_setup flag, or setting a Sample's Specification), even though the submitted field itself is valid.

This skips the redundant whole-object validation on the update route. Each submitted field is still validated on set (so invalid input is still rejected), while creation keeps validating the full object, preserving the behavior added in #66.

Current behavior before PR

A partial update (POST update/<uid> with a single field) runs a full-object validation and can return 400 with errors for untouched fields, or fail on a behavior invariant.

Desired behavior after PR is merged

The update only validates the fields that were submitted; unrelated untouched fields are left alone. Submitting an invalid field is still rejected. Covered by a new Partial validation on update section in update.rst.

--
I confirm I have coded it according to PEP8 standards.

ramonski added a commit that referenced this pull request Jul 28, 2026
@ramonski
ramonski force-pushed the feature/partial-update-validation branch 2 times, most recently from 417c35d to 0ac89e4 Compare July 28, 2026 18:00
@ramonski
ramonski requested a review from xispa July 28, 2026 18:20
@ramonski ramonski added the Enhancement ✨ Improvement to existing functionality label Jul 28, 2026
update_object_with_data re-validated the whole object after applying the
record. Since the field managers already validate each submitted field on
set, that second pass only re-checks untouched fields, and fails when one
of them no longer passes a full validation: an Archetypes field holding a
stored legacy value, or a Dexterity behavior invariant like
IExcludeFromNavigationDefault. This blocked partial updates to setup
objects even when the submitted field itself was valid.

Skip the redundant whole-object validation on the update route; creation
still validates the full object (preserving #66).
@ramonski
ramonski force-pushed the feature/partial-update-validation branch from 0ac89e4 to 9bd7a20 Compare July 28, 2026 18:21
@ramonski
ramonski changed the base branch from 2.x to feature/fix-single-valued-uidreference July 28, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement ✨ Improvement to existing functionality

Development

Successfully merging this pull request may close these issues.

1 participant