{"record":{"id":"36bf8a75c9da4eb7","repo":"stalwartlabs/stalwart","slug":"the-size-of-the-request-payload-exceeds-the-maximu","errorCode":null,"errorMessage":"The size of the request payload exceeds the maximum of {max_size} bytes.","messagePattern":"The size of the request payload exceeds the maximum of (.+?) bytes\\.","errorType":"http","errorClass":"ScimError","httpStatus":413,"severity":"error","filePath":"crates/scim/src/request.rs","lineNumber":266,"sourceCode":"        access_token: Option<&'x AccessToken>,\n    ) -> Result<ScimContext<'x>> {\n        Ok(ScimContext {\n            server: self,\n            access_token: req.scim_access_token(access_token)?,\n            session_id: session.session_id,\n        })\n    }\n}\n\nasync fn fetch(\n    req: &mut HttpRequest,\n    session: &HttpSessionData,\n    max_size: usize,\n) -> Result<Vec<u8>> {\n    fetch_body(req, max_size, session.session_id)\n        .await\n        .ok_or_else(|| {\n            ScimResponseError::Scim(Error::new(413).with_detail(format!(\n                \"The size of the request payload exceeds the maximum of {max_size} bytes.\"\n            )))\n        })\n}\n\npub fn search_request(query: Option<&str>) -> Result<SearchRequest<'_>> {\n    match query {\n        Some(query) => SearchRequest::from_query(query).map_err(Into::into),\n        None => Ok(SearchRequest::default()),\n    }\n}\n\npub fn method_not_allowed(allow: &'static str) -> ScimResponseError {\n    ScimResponseError::Allow(\n        Error::new(405).with_detail(format!(\n            \"The HTTP method is not supported by this endpoint, allowed methods are {allow}.\"\n        )),\n        allow,","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/scim/src/request.rs#L248-L284","documentation":"A SCIM 413 error thrown by the `fetch` helper in crates/scim/src/request.rs when `fetch_body` returns None because the incoming HTTP request body exceeds the configured `max_size` bytes. The detail message states the configured byte limit, mirroring RFC 7644's maxPayloadSize behavior for regular (non-bulk) requests.","triggerScenarios":"`fetch` is called during `dispatch_scim_request` to read a request body; the body is larger than `max_size`, so `fetch_body` yields None and this error is raised.","commonSituations":"A client uploads a user with very large attributes/photos against a server with a tight body limit; a proxy or gateway lowers allowed body sizes; an integration was moved to a server with a smaller max_size configuration.","solutions":["Reduce the request payload size (drop or externalize large attributes such as base64 photos).","Raise the server's max_size configuration for SCIM request bodies if the limit is too strict for your workload.","Send large data via multiple smaller requests where the schema allows it."],"exampleFix":"// before\nuser[\"photos\"] = json!([{\"value\": base64_huge_image}]);\n// after\nuser[\"photos\"] = json!([{\"value\": \"https://cdn.example/img.jpg\"}]);","handlingStrategy":"validation","validationCode":"let body = serde_json::to_vec(&payload)?;\nif body.len() > MAX_BODY_SIZE { /* shrink payload: remove photos/large attrs */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Measure serialized request size before sending; keep a safety margin under max_size.","Avoid embedding large base64 blobs in SCIM payloads.","Align client-side limits with the server's configured max_size."],"tags":["scim","http-413","request-body"],"backgroundTag":"payload-too-large","analyzedSha":"e96200385781a6a9995a8b839ac27d6c75a983ee","analyzedAt":"2026-09-06T22:07:17.982Z","contentChangedAt":"2026-09-06T22:07:17.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}