{"record":{"id":"bcb82a72d922b76b","repo":"affaan-m/ECC","slug":"program-exited-with-status","errorCode":null,"errorMessage":"{program} exited with {status}","messagePattern":"(.+?) exited with (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/notifications.rs","lineNumber":395,"sourceCode":"            \"content\": message,\n            \"allowed_mentions\": {\n                \"parse\": []\n            }\n        }),\n    }\n}\n\n#[cfg(not(test))]\nfn run_notification_command(program: &str, args: &[String]) -> Result<()> {\n    let status = std::process::Command::new(program)\n        .args(args)\n        .status()\n        .with_context(|| format!(\"launch {program}\"))?;\n\n    if status.success() {\n        Ok(())\n    } else {\n        anyhow::bail!(\"{program} exited with {status}\");\n    }\n}\n\n#[cfg(test)]\nfn run_notification_command(_program: &str, _args: &[String]) -> Result<()> {\n    Ok(())\n}\n\n#[cfg(not(test))]\nfn send_webhook_request(target: &WebhookTarget, payload: serde_json::Value) -> Result<()> {\n    let agent = ureq::Agent::config_builder()\n        .timeout_connect(Some(std::time::Duration::from_secs(5)))\n        .timeout_recv_response(Some(std::time::Duration::from_secs(5)))\n        .build()\n        .new_agent();\n    let response = agent\n        .post(&target.url)\n        .send_json(payload)","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/notifications.rs#L377-L413","documentation":"Thrown by run_notification_command (non-test build) after it successfully launches the configured notify program but that program exits with a non-zero status. The command ran but signaled failure, so the notification is treated as failed.","triggerScenarios":"A custom notification command (e.g. a shell script, sendmail, or osascript wrapper) configured in notifications exits non-zero: the script has a bug, references a missing binary, fails an internal check, or returns a non-zero code on success by mistake.","commonSituations":"A notify script missing its shebang or not executable; the script calls a binary not on PATH in the service's environment; a script that does 'exit 1' on a minor warning; permission errors writing a log file inside the script.","solutions":["Run the exact notify command and args manually in the same environment and observe its exit code and stderr.","Fix the script so it exits 0 on success; surface real failures with a clear non-zero code.","Ensure the program path is absolute or resolvable on the service's PATH, and the file is executable.","Check the status value in the message: on Unix, code > 128 means the program was killed by a signal (e.g. 137 = SIGKILL, often OOM).","If the script legitimately warns but should still succeed, make it exit 0 and log the warning instead."],"exampleFix":"# before: notify.sh exits non-zero on a harmless warning\n#!/bin/sh\nnotify-send \"$1\" || exit 1\n\n# after: treat a missing notify-send as best-effort\n#!/bin/sh\nnotify-send \"$1\" 2>/dev/null || true\nexit 0","handlingStrategy":"try-catch","validationCode":"use std::path::Path;\nfn notify_program_runnable(program: &str) -> bool {\n    Path::new(program).is_absolute() && Path::new(program).is_file()\n        || which::which(program).is_ok()\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = run_notification_command(program, args) {\n    log::warn!(\"notification command {program} failed: {e:#}; notification skipped\");\n}","preventionTips":["Test the notify script manually in the service environment before relying on it.","Use an absolute path and mark the script executable.","Treat notification failures as non-fatal so they do not break the main flow."],"tags":["notifications","process","cli","config"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}