From 27faa9f3ad63207664f5b1d4d706399199303869 Mon Sep 17 00:00:00 2001 From: mdecimus Date: Mon, 14 Jul 2025 19:32:40 +0200 Subject: [PATCH] Fix queue migration --- crates/migration/src/queue.rs | 5 +++-- crates/store/src/write/serialize.rs | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/migration/src/queue.rs b/crates/migration/src/queue.rs index 44c19630..88adced2 100644 --- a/crates/migration/src/queue.rs +++ b/crates/migration/src/queue.rs @@ -179,7 +179,7 @@ pub(crate) async fn migrate_queue_v012(server: &Server) -> trc::Result<()> { .await .and_then(|archive| { if let Some(archive) = archive { - archive.deserialize::().map(Some) + archive.deserialize_untrusted::().map(Some) } else { Ok(None) } @@ -209,7 +209,7 @@ pub(crate) async fn migrate_queue_v012(server: &Server) -> trc::Result<()> { .await .and_then(|archive| { if let Some(archive) = archive { - archive.deserialize::().map(Some) + archive.deserialize_untrusted::().map(Some) } else { Ok(None) } @@ -395,6 +395,7 @@ pub struct LegacyMessage { pub quota_keys: Vec, #[serde(skip)] + #[rkyv(with = rkyv::with::Skip)] pub span_id: u64, } diff --git a/crates/store/src/write/serialize.rs b/crates/store/src/write/serialize.rs index a917aff7..66b73495 100644 --- a/crates/store/src/write/serialize.rs +++ b/crates/store/src/write/serialize.rs @@ -302,6 +302,23 @@ impl Archive { }) } + pub fn deserialize_untrusted(&self) -> trc::Result + where + T: rkyv::Archive, + T::Archived: for<'a> rkyv::bytecheck::CheckBytes< + rkyv::api::high::HighValidator<'a, rkyv::rancor::Error>, + > + rkyv::Deserialize>, + { + self.unarchive_untrusted::().and_then(|input| { + rkyv::deserialize(input).map_err(|err| { + trc::StoreEvent::DeserializeError + .ctx(trc::Key::Value, self.as_bytes()) + .caused_by(trc::location!()) + .reason(err) + }) + }) + } + pub fn to_unarchived(&self) -> trc::Result::Archived>> where T: rkyv::Archive,