Skip to main content

extract_account_id

Function extract_account_id 

Source
pub fn extract_account_id(
    args: Value,
) -> Result<(Id, Map<String, Value>), JmapError>
Expand description

Extract accountId from a JMAP method arguments envelope and return both the extracted Id and the remaining argument map.

The caller passes the full args: Value from the method invocation by value; this function destructures it once, so handlers do not have to repeat the let Value::Object(mut args) = args else { ... } pattern after every call.

§Errors

Returns invalidArguments with:

  • "arguments must be an object containing accountId" when args is not a JSON object.
  • "accountId is required" when the field is missing or not a string.
  • "accountId is not a valid Id: <reason>" when the field is a string but does not satisfy the RFC 8620 §1.2 Id grammar (Id::new_validated). Catches empty strings, strings longer than 255 bytes, and strings containing characters outside the SAFE-CHAR set (%x21 / %x23-7E — visible ASCII excluding "). bd:JMAP-wlip.5 closed the previous silent-pass-through behaviour where a malformed accountId reached the backend’s account_exists call and surfaced as either notFound or a storage-layer parse error, depending on the backend.