{"record":{"id":"14bcc2afc8f7d282","repo":"xai-org/grok-build","slug":"targeted-fetch-task-failed-e","errorCode":null,"errorMessage":"targeted fetch task failed: {e}","messagePattern":"targeted fetch task failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-workspace/src/session/git.rs","lineNumber":2197,"sourceCode":"async fn spawn_targeted_fetch(git_root: &Path, spec: &str, kind: FetchKind) -> AsyncFetchOutcome {\n    let fetch_root = git_root.to_path_buf();\n    let fetch_spec = spec.to_owned();\n    match tokio::time::timeout(\n        crate::restore_fetch::RESTORE_FETCH_BUDGET + crate::restore_fetch::RESTORE_FETCH_JOIN_SLACK,\n        tokio::task::spawn_blocking(move || match kind {\n            FetchKind::CheckoutRef => {\n                crate::restore_fetch::fetch_checkout_target_if_missing(&fetch_root, &fetch_spec)\n            }\n            FetchKind::CommitOidOnly => {\n                crate::restore_fetch::fetch_commit_if_missing(&fetch_root, &fetch_spec)\n            }\n        }),\n    )\n    .await\n    {\n        Err(_) => AsyncFetchOutcome::Abandoned,\n        Ok(Err(e)) => {\n            AsyncFetchOutcome::Completed(Err(anyhow::anyhow!(\"targeted fetch task failed: {e}\")))\n        }\n        Ok(Ok(result)) => AsyncFetchOutcome::Completed(result),\n    }\n}\n/// Checkout `head_commit` (full oid or simple ref), fetching from origin if needed.\npub(crate) async fn checkout_commit_with_fetch(\n    git_root: &Path,\n    head_commit: &str,\n    stash_if_dirty: bool,\n) -> CheckoutCommitResponse {\n    if let Some(current) = get_current_commit(git_root).await\n        && current == head_commit\n        && git_cli(git_root, &[\"cat-file\", \"-t\", head_commit])\n            .await\n            .is_ok()\n    {\n        return CheckoutCommitResponse {\n            checked_out: true,","sourceCodeStart":2179,"sourceCodeEnd":2215,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-workspace/src/session/git.rs#L2179-L2215","documentation":"This error wraps any failure returned by the spawned async targeted-fetch task. The wrapper awaits a `JoinHandle`; if the task itself completes with `Err(e)`, the original error is re-wrapped as `AsyncFetchOutcome::Completed(Err(...))` with the message 'targeted fetch task failed: {e}', so the root cause (network, auth, ref not found, etc.) is in the formatted `{e}`.","triggerScenarios":"The inner fetch future fails for any reason — remote unreachable, bad SSH/HTTPS credentials, missing refspec, or non-zero `git fetch` exit — during the targeted fetch used before checkout.","commonSituations":"Offline or firewalled environment; expired GitHub token / SSH key not loaded; fetching a branch deleted on the remote; proxy misconfiguration.","solutions":["Read the wrapped `{e}` in the message to find the root cause","Run `git fetch origin <ref>` manually in the workspace to reproduce and see git's stderr","Fix credentials (refresh token, `ssh-add`) or network/proxy settings","Verify the target branch/ref still exists on origin"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"let out = std::process::Command::new(\"git\").args([\"ls-remote\",\"origin\"]).output()?;\nif !out.status.success() { eprintln!(\"remote unreachable: {}\", String::from_utf8_lossy(&out.stderr)); }","typeGuard":null,"tryCatchPattern":"match outcome {\n    AsyncFetchOutcome::Completed(Err(e)) if e.to_string().contains(\"targeted fetch task failed\") => {\n        // inspect root cause in {e}: retry with backoff or surface to user\n    }\n    _ => {}\n}","preventionTips":["Check remote connectivity/credentials before checkout flows","Handle offline environments with a retry/backoff policy","Verify the target ref exists on origin before fetching"],"tags":["git","fetch","network","async"],"backgroundTag":"git-fetch-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}