{"record":{"id":"9352813b98196307","repo":"stalwartlabs/stalwart","slug":"sieve-test-failed","errorCode":null,"errorMessage":"Sieve test failed: {}","messagePattern":"Sieve test failed: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/email/src/sieve/ingest.rs","lineNumber":502,"sourceCode":"                                    arguments,\n                                },\n                            )\n                            .await;\n                    }\n                    Event::CreatedMessage { message, .. } => {\n                        messages.push(SieveMessage {\n                            raw_message: message.into(),\n                            file_into: Vec::new(),\n                            flags: Vec::new(),\n                            did_file_into: false,\n                        });\n                        input = true.into();\n                    }\n                },\n\n                #[cfg(feature = \"test_mode\")]\n                Err(sieve::runtime::RuntimeError::ScriptErrorMessage(err)) => {\n                    panic!(\"Sieve test failed: {}\", err);\n                }\n\n                Err(err) => {\n                    trc::event!(\n                        Sieve(SieveEvent::RuntimeError),\n                        Reason = err.to_string(),\n                        SpanId = session_id\n                    );\n\n                    input = true.into();\n                }\n            }\n        }\n\n        // Fail-safe, no discard and no keep seen, assume that something went wrong and file anyway.\n        if !do_deliver && !do_discard && !do_redirect {\n            messages[0].file_into.push(INBOX_ID);\n        }","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/email/src/sieve/ingest.rs#L484-L520","documentation":"When the `test_mode` feature is enabled, a Sieve script executing the `error` command during message delivery produces RuntimeError::ScriptErrorMessage. Instead of being logged as a runtime event like other errors, this specific variant is treated as an intentional test signal and panics with \"Sieve test failed: {err}\", so test harnesses can assert delivery behavior. In normal (non-test) builds this variant cannot occur because the code is compiled out.","triggerScenarios":"Delivering a message to a Sieve script (sieve_script_ingest, invoked from deliver_message) that executes a Sieve `error` command, while the binary was built with `--features test_mode`. The panic message contains the script's error text.","commonSituations":"Running the test suite with test scripts that intentionally call `error;` to verify failure paths; enabling test_mode in a development build and pointing a mailbox at a script that still contains an `error` action.","solutions":["If this is a test failure, read the embedded script error text and fix the Sieve script or the test expectation.","Remove the `error` command from the Sieve script if delivery should succeed.","Do not build or run production deployments with the test_mode feature; without it, script errors are reported as Sieve RuntimeError events instead."],"exampleFix":"# before (script.sieve)\nrequire [\"fileinto\"];\nerror;\n# after\nrequire [\"fileinto\"];\nfileinto \"INBOX\";","handlingStrategy":"fallback","validationCode":"// scan deployed Sieve scripts for the error action before enabling delivery:\n// grep -l '\\berror;' ~/.sieve/*.sieve","typeGuard":null,"tryCatchPattern":"// in test harnesses, catch the panic to assert the script's error message:\nlet result = std::panic::catch_unwind(|| deliver_message(msg));\nassert!(result.is_err(), \"expected Sieve error command to abort delivery\");","preventionTips":["Remove `error;` commands from production Sieve scripts.","Only build with the test_mode feature in CI/test environments.","Document that test_mode turns Sieve `error` into a process panic, not a logged event."],"tags":["sieve","email","test-mode","rust"],"backgroundTag":"script-runtime-error","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"}