{"record":{"id":"834f3114051d3d75","repo":"stalwartlabs/stalwart","slug":"internal-server-error","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":"ScimError","httpStatus":500,"severity":"critical","filePath":"crates/scim-proto/src/message/error.rs","lineNumber":195,"sourceCode":"\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\n    pub fn is_client_error(&self) -> bool {\n        (400..500).contains(&self.status)\n    }\n}\n\nimpl Serialize for Error {\n    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>\n    where\n        S: Serializer,\n    {\n        let mut map = serializer.serialize_map(None)?;\n        map.serialize_entry(\"schemas\", &[MESSAGE_ERROR])?;","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/scim-proto/src/message/error.rs#L177-L213","documentation":"A SCIM Error with HTTP status 500 (\"Internal Server Error\"), built by `Error::internal_error()`. The library uses it to represent unexpected server-side failures while processing a SCIM request — the fault is in the server, not the client request.","triggerScenarios":"A server-side handler catches an unexpected condition (storage failure, panic recovered, malformed internal state) and responds by constructing `Error::internal_error()`.","commonSituations":"Backend database outages, unhandled panics in request handlers, misconfigured storage backends, or bugs introduced by a server version upgrade.","solutions":["Inspect the SCIM server logs for the corresponding request/trace to find the underlying failure.","Retry the request after confirming the server is healthy (500s may be transient during restarts or DB blips).","If reproducible, report/fix the server-side bug; the client request is usually not at fault."],"exampleFix":"// before\nloop { client.get_user(id).await?; }\n// after\nmatch client.get_user(id).await {\n    Err(e) if e.status() == 500 => backoff_retry(|| client.get_user(id)).await?,\n    other => other?,\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.get_user(id).await {\n    Err(e) if e.status() == 500 => backoff::retry(3, || client.get_user(id)).await?,\n    other => other?,\n}","preventionTips":["Treat 500s as server-side; alert on them rather than blaming request construction.","Use bounded exponential backoff for retries; do not hot-loop.","Monitor SCIM server health/log correlation IDs shipped with error responses."],"tags":["scim","http-500","server-error"],"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"}