{"record":{"id":"8a256f301400e81f","repo":"xai-org/grok-build","slug":"label-exited-with","errorCode":null,"errorMessage":"{label} exited with {}: {}","messagePattern":"(.+?) exited with (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shared/src/clipboard.rs","lineNumber":784,"sourceCode":"            // regions cannot overlap.\n            unsafe {\n                std::ptr::copy_nonoverlapping(bytes_ptr as *const u8, buf.as_mut_ptr(), len);\n            }\n            Some(super::ImageData {\n                data: buf,\n                mime_type: mime.to_owned(),\n            })\n        })\n    }\n\n    pub(super) fn checked_command_stdout(\n        label: &str,\n        output: std::io::Result<std::process::Output>,\n    ) -> anyhow::Result<Vec<u8>> {\n        let output = output.map_err(|error| anyhow::anyhow!(\"failed to run {label}: {error}\"))?;\n        if !output.status.success() {\n            let stderr = String::from_utf8_lossy(&output.stderr);\n            anyhow::bail!(\"{label} exited with {}: {}\", output.status, stderr.trim());\n        }\n        Ok(output.stdout)\n    }\n\n    fn attachments_probe_temp_paths() -> (std::path::PathBuf, std::path::PathBuf, std::path::PathBuf)\n    {\n        let temp_dir = std::env::temp_dir();\n        (\n            temp_dir.join(\"grok-clipboard-probe.png\"),\n            temp_dir.join(\"grok-clipboard-probe.tiff\"),\n            temp_dir.join(\"grok-clipboard-probe.jpg\"),\n        )\n    }\n\n    fn read_clipboard_image_from_class(\n        class: &str,\n        path_png: &std::path::Path,\n        path_tiff: &std::path::Path,","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shared/src/clipboard.rs#L766-L802","documentation":"`checked_command_stdout` wraps external clipboard helper commands (osascript, pbpaste, etc.) and bails when the child process exits non-zero, embedding the exit status and trimmed stderr in the message. It surfaces the underlying tool's own failure text to the caller.","triggerScenarios":"Calling set_text/get_text/get_image or the macOS attachments osascript flow when the spawned helper exits non-zero — e.g. osascript blocked by TCC permissions, pbpaste with no pasteboard access, or the binary missing/segfaulting.","commonSituations":"macOS Terminal/IDE lacking Automation permissions for clipboard Apple events; sandboxed or SSH sessions where the helper cannot reach the pasteboard; a distro where the installed clipboard tool prints an error on stderr.","solutions":["Read the stderr portion of the message to see the helper's own diagnostic and fix that root cause","On macOS grant the terminal app Accessibility/Automation permission to control clipboard (System Settings > Privacy & Security)","Verify the helper binary exists and works by running it manually with the same arguments","Retry the clipboard operation — transient pasteboard contention can cause one-shot failures"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify the helper works before relying on it (macOS example)\nfn helper_ok(bin: &str) -> bool {\n    std::process::Command::new(bin).arg(\"-e\").arg(\"return 0\").output()\n        .map(|o| o.status.success()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match clipboard::get_text() {\n    Ok(t) => use_text(&t),\n    Err(e) if e.to_string().contains(\"exited with\") => {\n        eprintln!(\"clipboard helper failed: {e}\");\n        retry_with_backoff(3, || clipboard::get_text());\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["On macOS, pre-grant terminal Automation permissions so osascript/pbpaste never fail on TCC","Log the exit status + stderr portion of the message for the root cause","Retry once or twice — pasteboard contention can be transient","Run helper binaries once at startup as a health check"],"tags":["clipboard","process","macos"],"backgroundTag":"clipboard-command-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}