{"record":{"id":"0145deb8da80a40f","repo":"Hmbown/CodeWhale","slug":"telemetry-privacy-lock-is-held","errorCode":null,"errorMessage":"telemetry privacy lock is held","messagePattern":"telemetry privacy lock is held","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/telemetry/src/envelope.rs","lineNumber":84,"sourceCode":"        let path = buffer::install_id_path(root);\n        let existing = std::fs::read_to_string(&path)\n            .ok()\n            .and_then(|body| serde_json::from_str::<InstallId>(&body).ok())\n            .filter(|record| uuid::Uuid::parse_str(record.install_id.trim()).is_ok())\n            .filter(|record| !is_expired(&record.rotated_at));\n        if let Some(record) = existing {\n            return Ok(record);\n        }\n        let record = InstallId {\n            schema_version: 1,\n            install_id: uuid::Uuid::new_v4().to_string(),\n            rotated_at: now_rfc3339(),\n        };\n        codewhale_config::persistence::atomic_write_json(&path, &record)\n            .with_context(|| format!(\"failed to write {}\", path.display()))?;\n        Ok(record)\n    })?\n    .ok_or_else(|| anyhow::anyhow!(\"telemetry privacy lock is held\"))\n}\n\nfn is_expired(rotated_at: &str) -> bool {\n    let Ok(parsed) = chrono::DateTime::parse_from_rfc3339(rotated_at) else {\n        // An unreadable timestamp is treated as expired: minting a fresh random\n        // id is always the safe direction.\n        return true;\n    };\n    let age = chrono::Utc::now().signed_duration_since(parsed.with_timezone(&chrono::Utc));\n    age.num_days() >= ROTATION_DAYS\n}\n\n/// Read `state.json`, or a default when it is missing or unreadable.\n#[must_use]\npub fn read_state(root: &Path) -> TelemetryState {\n    std::fs::read_to_string(buffer::state_path(root))\n        .ok()\n        .and_then(|body| serde_json::from_str::<TelemetryState>(&body).ok())","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/telemetry/src/envelope.rs#L66-L102","documentation":"read_or_create_install_id takes a privacy lock around install-id creation; this error means the lock was already held — concurrent initialization or a leaked guard — so the caller must not read or mint an install id concurrently.","triggerScenarios":"Thrown at crates/telemetry/src/envelope.rs:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry once the current privacy-buffer operation releases the lock.","If it persists, a lock was leaked by an earlier panic — restart the process."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}