Skip to main content

check_patch_paths

Function check_patch_paths 

Source
pub fn check_patch_paths(
    patch: &Map<String, Value>,
) -> Result<(), PatchPathError>
Expand description

Check the RFC 8620 §5.3 PatchObject errors that patch alone determines, without the object it applies to.

A server whose spec orders these before other checks calls this first; draft-ietf-jmap-metadata-04 §3.2 says “Patch errors that can be determined from the request alone (for example, two paths where one is a prefix of the other) MUST be reported with “invalidPatch” before rule 1 is evaluated“. apply_patch_object runs the same check, so calling both is redundant but harmless.

§Errors

Returns PatchPathError::InvalidEscape for a key with a ~ not followed by 0 or 1, PatchPathError::DepthExceeded for an entry over the MAX_MERGE_PATCH_DEPTH cap, and PatchPathError::PrefixConflict when the decoded pointer of one key is a whole-segment prefix of another ("alerts" and "alerts/1/offset" conflict; "alert" and "alerts/x" do not).