diff --git a/crates/torii/core/src/processors/store_del_record.rs b/crates/torii/core/src/processors/store_del_record.rs index cf9c79f79f..f6b34db24a 100644 --- a/crates/torii/core/src/processors/store_del_record.rs +++ b/crates/torii/core/src/processors/store_del_record.rs @@ -4,7 +4,7 @@ use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::world::WorldContractReader; use starknet::core::types::Event; use starknet::providers::Provider; -use tracing::info; +use tracing::{debug, info}; use super::{EventProcessor, EventProcessorConfig}; use crate::sql::Sql; @@ -55,12 +55,15 @@ where // This can happen if only specific namespaces are indexed. let model = match db.model(event.selector).await { Ok(m) => m, - Err(e) => { - if e.to_string().contains("no rows") { - return Ok(()); - } - return Err(e); + Err(e) if e.to_string().contains("no rows") => { + debug!( + target: LOG_TARGET, + selector = %event.selector, + "Model does not exist, skipping." + ); + return Ok(()); } + Err(e) => return Err(e), }; info!( diff --git a/crates/torii/core/src/processors/store_set_record.rs b/crates/torii/core/src/processors/store_set_record.rs index 16943cb1fb..cc602fd868 100644 --- a/crates/torii/core/src/processors/store_set_record.rs +++ b/crates/torii/core/src/processors/store_set_record.rs @@ -4,7 +4,7 @@ use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::world::WorldContractReader; use starknet::core::types::Event; use starknet::providers::Provider; -use tracing::info; +use tracing::{debug, info}; use super::{EventProcessor, EventProcessorConfig}; use crate::sql::utils::felts_to_sql_string; @@ -56,12 +56,15 @@ where // This can happen if only specific namespaces are indexed. let model = match db.model(event.selector).await { Ok(m) => m, - Err(e) => { - if e.to_string().contains("no rows") { - return Ok(()); - } - return Err(e); + Err(e) if e.to_string().contains("no rows") => { + debug!( + target: LOG_TARGET, + selector = %event.selector, + "Model does not exist, skipping." + ); + return Ok(()); } + Err(e) => return Err(e), }; info!( diff --git a/crates/torii/core/src/processors/store_update_record.rs b/crates/torii/core/src/processors/store_update_record.rs index c0179c7946..f94920e411 100644 --- a/crates/torii/core/src/processors/store_update_record.rs +++ b/crates/torii/core/src/processors/store_update_record.rs @@ -5,7 +5,7 @@ use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::world::WorldContractReader; use starknet::core::types::Event; use starknet::providers::Provider; -use tracing::info; +use tracing::{debug, info}; use super::{EventProcessor, EventProcessorConfig}; use crate::sql::Sql; @@ -59,12 +59,15 @@ where // This can happen if only specific namespaces are indexed. let model = match db.model(event.selector).await { Ok(m) => m, - Err(e) => { - if e.to_string().contains("no rows") { - return Ok(()); - } - return Err(e); + Err(e) if e.to_string().contains("no rows") => { + debug!( + target: LOG_TARGET, + selector = %event.selector, + "Model does not exist, skipping." + ); + return Ok(()); } + Err(e) => return Err(e), }; info!( diff --git a/crates/torii/core/src/processors/upgrade_event.rs b/crates/torii/core/src/processors/upgrade_event.rs index 8479d9ab05..da329501af 100644 --- a/crates/torii/core/src/processors/upgrade_event.rs +++ b/crates/torii/core/src/processors/upgrade_event.rs @@ -1,4 +1,4 @@ -use anyhow::{Error, Ok, Result}; +use anyhow::{Error, Result}; use async_trait::async_trait; use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::model::ModelReader; @@ -56,7 +56,21 @@ where // Called model here by language, but it's an event. Torii rework will make clear // distinction. - let model = db.model(event.selector).await?; + + // If the model does not exist, silently ignore it. + // This can happen if only specific namespaces are indexed. + let model = match db.model(event.selector).await { + Ok(m) => m, + Err(e) if e.to_string().contains("no rows") => { + debug!( + target: LOG_TARGET, + selector = %event.selector, + "Model does not exist, skipping." + ); + return Ok(()); + } + Err(e) => return Err(e), + }; let name = model.name; let namespace = model.namespace; let prev_schema = model.schema; diff --git a/crates/torii/core/src/processors/upgrade_model.rs b/crates/torii/core/src/processors/upgrade_model.rs index 403e1e17fd..0b7e36820d 100644 --- a/crates/torii/core/src/processors/upgrade_model.rs +++ b/crates/torii/core/src/processors/upgrade_model.rs @@ -1,4 +1,4 @@ -use anyhow::{Error, Ok, Result}; +use anyhow::{Error, Result}; use async_trait::async_trait; use dojo_world::contracts::abigen::world::Event as WorldEvent; use dojo_world::contracts::model::ModelReader; @@ -54,7 +54,21 @@ where } }; - let model = db.model(event.selector).await?; + // If the model does not exist, silently ignore it. + // This can happen if only specific namespaces are indexed. + let model = match db.model(event.selector).await { + Ok(m) => m, + Err(e) if e.to_string().contains("no rows") => { + debug!( + target: LOG_TARGET, + selector = %event.selector, + "Model does not exist, skipping." + ); + return Ok(()); + } + Err(e) => return Err(e), + }; + let name = model.name; let namespace = model.namespace; let prev_schema = model.schema;