{"record":{"id":"3e2814f51c57047f","repo":"astrid-runtime/astrid","slug":"anyhow-anyhow-error","errorCode":null,"errorMessage":"anyhow::anyhow!(error)","messagePattern":"anyhow::anyhow!\\(error\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/distro/lock.rs","lineNumber":161,"sourceCode":"/// API. JSON field order is fixed by the typed struct declaration.\npub(crate) fn provenance_digest(provenance: &DistroProvenance) -> anyhow::Result<String> {\n    let bytes = serde_json::to_vec(provenance).context(\"encode distro provenance\")?;\n    Ok(format!(\"blake3:{}\", blake3::hash(&bytes).to_hex()))\n}\n\n/// Read the target principal's durable distro record through the daemon.\npub(crate) async fn load_lock_from_daemon(\n    principal: &PrincipalId,\n) -> anyhow::Result<Option<DistroLock>> {\n    let mut client = crate::admin_client::connect_as_active_agent().await?;\n    let response = client\n        .request(AdminRequestKind::DistroLockGet {\n            principal: principal.clone(),\n        })\n        .await?;\n    match response {\n        AdminResponseBody::DistroLock(lock) => Ok((*lock).map(from_provenance)),\n        AdminResponseBody::Error(error) => Err(anyhow::anyhow!(error)),\n        other => Err(anyhow::anyhow!(\n            \"unexpected distro lock response: {other:?}\"\n        )),\n    }\n}\n\n/// Replace the target principal's durable distro record with an optimistic\n/// compare-and-swap. A missing current record is an intentional create.\npub(crate) async fn write_lock_to_daemon(\n    principal: &PrincipalId,\n    lock: &DistroLock,\n) -> anyhow::Result<()> {\n    let mut client = crate::admin_client::connect_as_active_agent().await?;\n    let current = client\n        .request(AdminRequestKind::DistroLockGet {\n            principal: principal.clone(),\n        })\n        .await?;","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/distro/lock.rs#L143-L179","documentation":"In `load_lock_from_daemon`, the daemon responded to a `DistroLockGet` admin request with `AdminResponseBody::Error(error)`; the CLI re-raises that daemon-side error string as an anyhow error. It is a pass-through of a server-side failure fetching the distro lock for the given principal, not a client-side parse or connection issue. Any other unexpected response variant gets a distinct 'unexpected distro lock response' error.","triggerScenarios":"Calling `regenerate_distro_lock` -> `load_lock_from_daemon` where the daemon returns DistroLock error for the request: lock file missing/corrupt on the daemon side, principal lacks access to the lock, or the daemon's lock store is unavailable.","commonSituations":"Distro lock never generated before regeneration; running as a principal that isn't authorized for the distro lock admin operation; daemon's workspace state partially initialized so the lock lookup fails server-side.","solutions":["Read the re-raised daemon error text for the concrete server-side cause and address it there.","Generate the lock first (`astrid distro lock` / install flow) if it doesn't exist yet, then retry regeneration.","Verify the principal has admin rights for the distro lock operation; re-authenticate or use an admin principal.","Check daemon logs around the DistroLockGet handling for the underlying failure (missing/corrupt lock file)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight: only ask when a lock exists server-side\nmatch client.request(AdminRequestKind::DistroLockGet { principal }).await? {\n    AdminResponseBody::DistroLock(_) => Ok(()),\n    AdminResponseBody::Error(e) => Err(anyhow!(\"daemon lock unavailable: {e}\")),\n    other => Err(anyhow!(\"unexpected response: {other:?}\")),\n}","typeGuard":null,"tryCatchPattern":"match load_lock_from_daemon(&client, &principal).await {\n    Err(e) => {\n        eprintln!(\"daemon refused DistroLockGet: {e}\");\n        // fall back to regenerating locally if authorized\n        regenerate_lock_locally(&principal).await\n    }\n    ok => ok,\n}","preventionTips":["Generate the distro lock (install/lock flow) before attempting regeneration that reads it.","Use an admin-authorized principal for DistroLockGet requests.","Keep daemon and CLI versions matched to avoid response-shape drift.","Check daemon logs when DistroLockGet errors to find the server-side root cause."],"tags":["distro","daemon","ipc","lock-file"],"backgroundTag":"api-error-response","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}