Skip to main content

check_read_only_patch

Function check_read_only_patch 

Source
pub async fn check_read_only_patch<B, O>(
    backend: &B,
    caller: &B::CallerCtx,
    account_id: &Id,
    id: &Id,
    patch: &mut Map<String, Value>,
) -> Result<bool, Value>
Expand description

Check a /set update patch of the stored object id against the server-set and immutable properties of O, and report a no-op.

RFC 8620 §5.3: “Any server-set properties MAY be included in the patch if their value is identical to the current server value (before applying the patches to the object). Otherwise, the update MUST be rejected with an “invalidProperties” SetError.“ The stored object is fetched only when the patch names such a property or is empty; then strip_read_only_patch rejects a changed value and drops the identical ones, leaving only the client changes for the handler’s own checks.

Returns Ok(true) when nothing is left to apply, for a literal {} or a patch of identical server-set values: the update succeeds as a no-op, with no write, updated mapping id to null, and the state unchanged. A missing object is notFound, whether the patch is empty or names a read-only key: existence is checked before shape, so a caller learns nothing about the properties of an object it cannot see.

§Errors

The notUpdated value: notFound for a missing object, the invalidProperties SetError, or serverFail when the fetch fails.