Skip to content

Commit

Permalink
chore: log a warning when an empty transaction is committed [WPB-11743]
Browse files Browse the repository at this point in the history
An empty transaction could be an indication that the app consuming
core crypto contains a programming error.
  • Loading branch information
typfel committed Nov 21, 2024
1 parent 9c67569 commit fe7f2b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions keystore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ default = ["proteus-keystore"]
proteus-keystore = ["dep:proteus-traits"]
ios-wal-compat = ["dep:security-framework", "dep:security-framework-sys", "dep:core-foundation"]
idb-regression-test = []
log-queries = ["dep:log", "rusqlite/trace"]
log-queries = ["rusqlite/trace"]
serde = ["dep:serde"]
dummy-entity = ["serde"]

Expand All @@ -48,7 +48,7 @@ openmls_traits = { workspace = true }
openmls_basic_credential = { workspace = true }
openmls_x509_credential = { workspace = true }
serde = { workspace = true, features = ["derive"], optional = true }
log = { workspace = true, optional = true }
log = { workspace = true }
proteus-traits = { workspace = true, optional = true }
itertools.workspace = true

Expand Down
7 changes: 3 additions & 4 deletions keystore/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl KeystoreTransaction {
/// Identity from the perspective of this function is determined by the output of [crate::entities::Entity::merge_key].
///
/// Further, the output list of records is built with respect to the provided [EntityFindParams]
/// and the deleted records cached in this [Self] instance.
/// and the deleted records cached in this [Self] instance.
async fn merge_records<E: crate::entities::Entity<ConnectionType = KeystoreDatabaseConnection>>(
&self,
records_a: Vec<E>,
Expand Down Expand Up @@ -250,7 +250,7 @@ impl KeystoreTransaction {
/// (identifier_01, MlsCredential),
/// (identifier_02, MlsSignatureKeyPair),
/// ],
/// proteus_types: [
/// proteus_types: [
/// (identifier_03, ProteusPrekey),
/// (identifier_04, ProteusIdentity),
/// (identifier_05, ProteusSession)
Expand Down Expand Up @@ -288,8 +288,7 @@ macro_rules! commit_transaction {
}

if tables.is_empty() {
// If we didn't do this early return, creating the transaction would fail.
// Once logging is available, we should log a warning here though. (WPB-11743)
log::warn!("Empty transaction was committed, this could be an indication of a programming error");
return Ok(());
}
let tx = conn.new_transaction(&tables).await?;
Expand Down

0 comments on commit fe7f2b4

Please sign in to comment.