{"record":{"id":"1e33e738f23f527b","repo":"xai-org/grok-build","slug":"decode-task-panicked-e","errorCode":null,"errorMessage":"decode task panicked: {e}","messagePattern":"decode task panicked: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-update/src/auto_update.rs","lineNumber":1403,"sourceCode":"        let mut capped = decoder.take(MAX_DECODED_BYTES + 1);\n        let written = std::io::copy(&mut capped, &mut out).context(\"decode\")?;\n        if written > MAX_DECODED_BYTES {\n            anyhow::bail!(\"decoded artifact exceeds the {MAX_DECODED_BYTES}-byte cap\");\n        }\n        Ok(())\n    })\n    .await;\n    let _ = tokio::fs::remove_file(&comp_tmp).await;\n\n    match decoded {\n        Ok(Ok(())) => publish_downloaded_artifact(&bin_tmp, dest).await,\n        Ok(Err(e)) => {\n            let _ = tokio::fs::remove_file(&bin_tmp).await;\n            Err(e)\n        }\n        Err(e) => {\n            let _ = tokio::fs::remove_file(&bin_tmp).await;\n            Err(anyhow::anyhow!(\"decode task panicked: {e}\"))\n        }\n    }\n}\n\nasync fn download_cli_artifact_from_gcs(\n    gcs_base_url: &str,\n    object_name: &str,\n    dest: &std::path::Path,\n    with_progress: bool,\n) -> Result<()> {\n    let base = gcs_base_url.trim_end_matches('/');\n\n    for (suffix, codec) in [(\"zst\", Codec::Zstd), (\"gz\", Codec::Gzip)] {\n        let url = format!(\"{base}/{object_name}.{suffix}\");\n        match download_and_decode(&url, dest, codec, with_progress).await {\n            Ok(()) => return Ok(()),\n            Err(e) => tracing::debug!(\"compressed .{suffix} unusable, trying next: {e}\"),\n        }","sourceCodeStart":1385,"sourceCodeEnd":1421,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-update/src/auto_update.rs#L1385-L1421","documentation":"download_and_decode spawns a blocking task to decode a downloaded CLI artifact; this error is produced when that task panics (JoinError) instead of returning an Err. The temp binary file is deleted best-effort before returning. It signals the decode worker crashed — the artifact itself may be fine or corrupt; the panic obscured the reason.","triggerScenarios":"Calling download_and_decode (via download_cli_artifact_from_gcs) when the spawned decode closure panics — e.g. unwrap on malformed archive data, out-of-bounds slicing while decoding a corrupt artifact, or the decoder library panicking on bad input.","commonSituations":"Corrupt or truncated artifact downloaded from GCS causing the decoder to panic on unexpected bytes; codec mismatch (file not in the expected codec format); OOM aborts surfacing as panics on huge artifacts.","solutions":["Read the embedded panic message to identify which decode step crashed","Delete any leftover bin_tmp file and retry the download (corrupt artifacts are removed automatically, verify bin_tmp is gone)","Check that the artifact served by GCS matches the expected codec/encoding","Retry the update — if the artifact is corrupted server-side, the round-trip test will also fail"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// sanity-check the artifact before decoding\nlet meta = tokio::fs::metadata(&bin_tmp).await?;\nif meta.len() == 0 { anyhow::bail!(\"downloaded artifact is empty\"); }","typeGuard":null,"tryCatchPattern":"match download_and_decode(&url, &dest, &codec).await {\n    Err(e) if e.to_string().contains(\"decode task panicked\") => {\n        // remove leftover temp file and retry or fall back\n        let _ = tokio::fs::remove_file(&bin_tmp).await;\n        eprintln!(\"decode panicked: {e}\");\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Verify artifact integrity (hash/checksum) before decoding","Ensure the artifact matches the expected codec before decoding","Retry once on transient corruption from the network","Monitor the panic payload in the message to find the crashing decode step"],"tags":["tokio","panic","decoding","async"],"backgroundTag":"blocking-task-panicked","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}