{"record":{"id":"37d5941176c17e4b","repo":"xai-org/grok-build","slug":"no-encoded-bytes-to-persist","errorCode":null,"errorMessage":"no encoded bytes to persist","messagePattern":"no encoded bytes to persist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager-render/src/prompt_images.rs","lineNumber":1342,"sourceCode":"// -------------------------------------------------------------------------\n\n/// Persist image bytes into the session `images/` directory.\n///\n/// Creates the directory if it does not exist. Uses a UUID-v4 filename\n/// to avoid collisions (two pastes of the same image are independent).\n///\n/// On success:\n/// - Sets `img.session_image_path` to the written file.\n/// - Leaves `img.source_path` unchanged as the original display path.\n/// - Drops `encoded_bytes` from memory.\npub fn persist_to_session(\n    img: &mut PastedImage,\n    session_images_dir: &std::path::Path,\n) -> anyhow::Result<()> {\n    let bytes = img\n        .encoded_bytes\n        .as_ref()\n        .ok_or_else(|| anyhow::anyhow!(\"no encoded bytes to persist\"))?;\n\n    std::fs::create_dir_all(session_images_dir)?;\n\n    let ext = extension_for_mime(&img.mime_type);\n    let filename = format!(\"image-{}.{}\", uuid::Uuid::new_v4(), ext);\n    let path = session_images_dir.join(&filename);\n    // Atomic write: a crash mid-write leaves no partially-written final file.\n    let tmp_path = path.with_extension(format!(\"{ext}.tmp\"));\n    let write_result: anyhow::Result<()> = (|| {\n        use std::io::Write as _;\n        let mut f = std::fs::File::create(&tmp_path)?;\n        f.write_all(bytes)?;\n        f.sync_all()?;\n        drop(f);\n        std::fs::rename(&tmp_path, &path)?;\n        Ok(())\n    })();\n    if write_result.is_err() {","sourceCodeStart":1324,"sourceCodeEnd":1360,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager-render/src/prompt_images.rs#L1324-L1360","documentation":"Error \"no encoded bytes to persist\" thrown in xai-org/grok-build.","triggerScenarios":"Thrown at crates/codegen/xai-grok-pager-render/src/prompt_images.rs:1342 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}