{"record":{"id":"db6238f177c581fa","repo":"stalwartlabs/stalwart","slug":"the-number-of-operations-in-the-bulk-request-excee","errorCode":null,"errorMessage":"The number of operations in the bulk request exceeds the maxOperations ({max_operations}).","messagePattern":"The number of operations in the bulk request exceeds the maxOperations \\((.+?)\\)\\.","errorType":"http","errorClass":"ScimError","httpStatus":413,"severity":"error","filePath":"crates/scim-proto/src/message/error.rs","lineNumber":183,"sourceCode":"\n    pub fn forbidden(detail: impl Into<Cow<'static, str>>) -> Self {\n        Error::new(403).with_detail(detail)\n    }\n\n    pub fn not_found() -> Self {\n        Error::new(404)\n    }\n\n    pub fn conflict(detail: impl Into<Cow<'static, str>>) -> Self {\n        Error::new(409).with_detail(detail)\n    }\n\n    pub fn precondition_failed() -> Self {\n        Error::new(412)\n    }\n\n    pub fn max_operations_exceeded(max_operations: usize) -> Self {\n        Error::new(413).with_detail(format!(\n            \"The number of operations in the bulk request exceeds the maxOperations ({max_operations}).\"\n        ))\n    }\n\n    pub fn max_payload_size_exceeded(max_payload_size: usize) -> Self {\n        Error::new(413).with_detail(format!(\n            \"The size of the bulk operation exceeds the maxPayloadSize ({max_payload_size}).\"\n        ))\n    }\n\n    pub fn internal_error() -> Self {\n        Error::new(500)\n    }\n\n    pub fn not_implemented() -> Self {\n        Error::new(501)\n    }\n","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/scim-proto/src/message/error.rs#L165-L201","documentation":"A SCIM Error with status 413 built by `Error::max_operations_exceeded(max_operations)`. It is thrown when a SCIM bulk request contains more operations than the server's configured maxOperations limit, and the detail message states the configured maximum.","triggerScenarios":"Submitting a POST to /Bulk whose \"Operations\" array length exceeds the server's maxOperations configuration, triggering this constructor with that limit.","commonSituations":"Large initial provisioning syncs batch thousands of users into one bulk request; the server was reconfigured to a lower maxOperations while clients still send big batches; copying an integration between servers with different bulk limits.","solutions":["Split the bulk request into chunks of at most maxOperations operations each.","Read the server's /ServiceProviderConfig (bulk.maxOperations) and size batches accordingly before sending.","Reduce batch size in the integration's configuration and re-run the sync."],"exampleFix":"// before\nclient.bulk(all_operations).await?; // 5000 ops\n// after\nfor chunk in all_operations.chunks(max_operations) {\n    client.bulk(chunk.to_vec()).await?;\n}","handlingStrategy":"validation","validationCode":"let cfg = client.service_provider_config().await?;\nlet max_ops = cfg.bulk.as_ref().map(|b| b.max_operations).unwrap_or(default);\nassert!(operations.len() <= max_ops, \"split bulk request: {} > {}\", operations.len(), max_ops);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read bulk.maxOperations from /ServiceProviderConfig before batching.","Chunk bulk operations defensively with a margin below the limit.","Re-check limits after server upgrades or provider migrations."],"tags":["scim","http-413","bulk"],"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"}