feat: add ApplyPatch function for applying SCIM patch operations#197
Draft
feat: add ApplyPatch function for applying SCIM patch operations#197
Conversation
68fc209 to
64be047
Compare
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.
401757a to
d5e7ba4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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