{"record":{"id":"e336e73fe5254dc7","repo":"stalwartlabs/stalwart","slug":"conflict","errorCode":null,"errorMessage":"Conflict","messagePattern":"Conflict","errorType":"http","errorClass":"ScimError","httpStatus":409,"severity":"error","filePath":"crates/scim-proto/src/message/error.rs","lineNumber":175,"sourceCode":"            scim_type: Some(ScimType::Uniqueness),\n            detail: Some(detail.into()),\n        }\n    }\n\n    pub fn unauthorized() -> Self {\n        Error::new(401)\n    }\n\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","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/scim-proto/src/message/error.rs#L157-L193","documentation":"A SCIM Error with HTTP status 409 (\"Conflict\"), built by `Error::conflict(detail)` which attaches a human-readable detail. It signals that the request conflicts with the current state of the resource — typically a uniqueness constraint such as a userName or email that already exists.","triggerScenarios":"Creating (POST) or updating (PUT/PATCH) a resource whose unique attribute (userName, emails.value, externalId) collides with an existing record, causing the caller to construct `Error::conflict(\"...\")` with a descriptive message.","commonSituations":"User provisioning retries re-create an already-provisioned user; two identity sources provision the same email concurrently; a rename collides with an existing account.","solutions":["Query for the existing resource by the conflicting unique attribute and update (PUT/PATCH) it instead of creating a new one.","Make provisioning idempotent: on 409, treat the resource as existing and reconcile its attributes.","Adjust the incoming value so it no longer violates the uniqueness constraint."],"exampleFix":"// before\nclient.create_user(new_user).await?;\n// after\nmatch client.create_user(new_user).await {\n    Err(e) if e.status() == 409 => client.update_existing_user_by_username(new_user).await?,\n    other => other?,\n}","handlingStrategy":"try-catch","validationCode":"// check uniqueness before creating\nlet existing = client.query_users(format!(\"userName eq \\\"{u}\\\"\")).await?;\nif !existing.resources.is_empty() { /* update instead of create */ }","typeGuard":null,"tryCatchPattern":"match client.create_user(u).await {\n    Err(e) if e.status() == 409 => reconcile_existing(u).await?,\n    other => other?,\n}","preventionTips":["Make provisioning idempotent: on conflict, look up and PATCH the existing record.","Check /ServiceProviderConfig uniqueness constraints for the attributes you set.","Serialize concurrent provisioning jobs for the same identity."],"tags":["scim","http-409","conflict"],"backgroundTag":"http-error-response","analyzedSha":"e96200385781a6a9995a8b839ac27d6c75a983ee","analyzedAt":"2026-09-06T22:07:17.982Z","contentChangedAt":"2026-09-06T22:07:17.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}