{"record":{"id":"758928e5ecd9e02d","repo":"Hmbown/CodeWhale","slug":"agent-mail-ownership-denied-message-does-not-belo","errorCode":null,"errorMessage":"Agent Mail ownership denied: message does not belong to this destination","messagePattern":"Agent Mail ownership denied: message does not belong to this destination","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6462,"sourceCode":"                .collect::<Vec<_>>();\n            Ok(inbox)\n        })\n        .await\n        .context(\"Agent Mail inbox task panicked\")?\n    }\n\n    pub async fn mark_agent_mail_read(\n        &self,\n        thread_id: &str,\n        message_id: &AgentMailMessageId,\n    ) -> Result<AgentMailEnvelope> {\n        let thread = self.get_thread(thread_id).await?;\n        let address = agent_mail_address(&self.store.owner_id, &thread)?;\n        let envelope = {\n            let _mail_mutation = self.store.mail_mutation.lock();\n            let mut envelope = self.store.load_agent_mail(message_id)?;\n            if envelope.destination != address {\n                bail!(\"Agent Mail ownership denied: message does not belong to this destination\");\n            }\n            match envelope.status {\n                AgentMailStatus::Read => envelope,\n                AgentMailStatus::Delivered => {\n                    envelope.status = AgentMailStatus::Read;\n                    envelope.read_at = Some(Utc::now());\n                    self.store.save_agent_mail(&envelope)?;\n                    envelope\n                }\n                _ => bail!(\"Agent Mail can be marked read only after delivery\"),\n            }\n        };\n        self.emit_agent_mail_event(AGENT_MAIL_EVENT_READ, &envelope)\n            .await?;\n        Ok(envelope)\n    }\n\n    /// Withdraw a queued envelope before it starts delivery (#6176). Only","sourceCodeStart":6444,"sourceCodeEnd":6480,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L6444-L6480","documentation":"mark_agent_mail_read verifies the envelope's destination matches the thread it is being marked read in; a message id belonging to another thread is refused so read receipts cannot be forged across threads.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6462 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call mark_agent_mail_read with the message_id from the destination thread's own inbox.","Verify the thread id is the thread the envelope was delivered to."],"exampleFix":null,"handlingStrategy":"validation","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"}