Skip to content

feat: add ApplyPatch function for applying SCIM patch operations#197

Draft
q-uint wants to merge 7 commits intomasterfrom
feat/apply-patch
Draft

feat: add ApplyPatch function for applying SCIM patch operations#197
q-uint wants to merge 7 commits intomasterfrom
feat/apply-patch

Conversation

@q-uint
Copy link
Copy Markdown
Collaborator

@q-uint q-uint commented Mar 25, 2026

Add a generic ApplyPatch function that applies a sequence of patch operations (add, replace, remove) to resource attributes, resolving attribute paths against the provided schema and extensions.

This avoids every consumer having to independently implement the RFC 7644 Section 3.5.2 patch semantics, which is error-prone and duplicative.

Closes #171

@q-uint q-uint self-assigned this Mar 25, 2026
@q-uint q-uint force-pushed the feat/apply-patch branch 2 times, most recently from 68fc209 to 64be047 Compare March 26, 2026 15:37
q-uint added 7 commits March 28, 2026 09:22
Add a generic ApplyPatch function that applies a sequence of patch
operations (add, replace, remove) to resource attributes, resolving
attribute paths against the provided schema and extensions.

This avoids every consumer having to independently implement the
RFC 7644 Section 3.5.2 patch semantics, which is error-prone and
duplicative.
Validate readOnly and immutable attribute mutability per RFC 7644
Section 3.5.2 before applying add, remove, and replace operations.
Implement sub-attribute merging for replace on singular complex
attributes (Section 3.5.2.3) so unspecified sub-attributes are
left unchanged. Return noTarget error for remove without a path
(Section 3.5.2.2).
Enforce uniqueness of (type, value) pairs in multi-valued complex
attributes per RFC 7643 Section 2.4. Validation is applied both
during schema validation and after patch operations, returning a
uniqueness error when duplicates are detected.
RFC 7643 Section 2.4 requires that the primary attribute value "true"
appears no more than once in a multi-valued attribute. Add
HasDuplicatePrimary and HasPrimarySubAttr to detect violations during
both schema validation and patch application.
….5.2

Instead of rejecting duplicate primary values as an error during PATCH,
the server now automatically clears primary on existing values when a
new primary is added, as required by RFC 7644 Section 3.5.2. This
applies both to add operations and replace via value expressions.

Also changes duplicate (type, value) and duplicate primary validation
errors from uniqueness to invalidValue, which better matches the
error semantics described in RFC 7643.
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.

Question: is implementing a patch application function reasonable?

1 participant