{"record":{"id":"a33d31340f27a04d","repo":"jdx/mise","slug":"cache-agent-returned-an-unexpected-publish-respons","errorCode":null,"errorMessage":"cache agent returned an unexpected publish response","messagePattern":"cache agent returned an unexpected publish response","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/cache/rustc.rs","lineNumber":818,"sourceCode":"    let mut published = BTreeSet::new();\n    for (digest, source) in blobs {\n        if published.insert(digest.clone()) {\n            requests.push(AgentRequest::StoreBlob { digest, source });\n        }\n    }\n    requests.push(AgentRequest::StoreActionResult {\n        result: RemoteActionResult {\n            action: action.clone(),\n            metadata: Some(metadata.0),\n            output_root: Some(directory.0),\n            version: 1,\n        },\n    });\n    for response in session::request_agent(&requests)? {\n        match response {\n            AgentResponse::Stored { .. } | AgentResponse::ActionStored { .. } => {}\n            AgentResponse::Error { message } => bail!(message),\n            _ => bail!(\"cache agent returned an unexpected publish response\"),\n        }\n    }\n    Ok(())\n}\n\nfn staged_bytes(directory: &Path, name: &str, bytes: &[u8]) -> Result<(CacheDigest, PathBuf)> {\n    let path = directory.join(name);\n    std::fs::write(&path, bytes)?;\n    Ok((CacheDigest::blake3(bytes), path))\n}\n\n#[cfg(unix)]\nfn file_mode(metadata: &std::fs::Metadata) -> u32 {\n    use std::os::unix::fs::PermissionsExt as _;\n    metadata.permissions().mode() & 0o644\n}\n\n#[cfg(windows)]","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/cache/rustc.rs#L800-L836","documentation":"A reply to StoreBlob/StoreActionResult that is neither Stored, ActionStored, nor Error — e.g. Blobs or Hello (src/cache/rustc.rs:814-819). Responses are matched positionally across the batched request list on one JSON-lines stream, so a variant mismatch means the stream is skewed: a version-skewed agent, a stale socket, or a desynchronized connection. Publishing aborts with a warning; compilation results are unaffected.","triggerScenarios":"Publishing through MISE_CACHE_SOCKET inherited from a session spawned by a different mise build whose AgentResponse enum differs; a response stream desynchronized after a garbled line; a foreign process answering on the socket.","commonSituations":"Same wiring-skew contexts as the other 'unexpected ... response' errors: exported cache env vars, mixed mise versions, reused session directories.","solutions":["Restart the mise task/session so shim and agent share one binary and protocol","Unset inherited MISE_CACHE_* variables in profiles and CI images","Confirm one mise version is active for both the task runner and the shim"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# ensure the publishing shim and the agent share one mise build:\nmise --version\ntest -S \"$MISE_CACHE_SOCKET\" || echo 'stale or missing cache agent — restart the mise session'","typeGuard":"fn is_unexpected_publish(r: &AgentResponse) -> bool {\n    !matches!(r, AgentResponse::Stored { .. } | AgentResponse::ActionStored { .. } | AgentResponse::Error { .. })\n}","tryCatchPattern":null,"preventionTips":["Never carry MISE_CACHE_* across sessions, machines, or mise upgrades","Restart sessions after upgrading mise","Consider publish failures advisory: log and retry on the next build"],"tags":["rust","cache","agent","protocol","publish"],"backgroundTag":"agent-protocol-mismatch","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}