From 6cf149e4096f915f915f66bcbe78d106dc326e14 Mon Sep 17 00:00:00 2001 From: Manan Date: Fri, 24 Apr 2026 16:31:07 -0700 Subject: [PATCH 1/2] chore: use is_empty() instead of .len() == 0 / .len() > 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mechanical Clippy-style refactor across 21 files (49 occurrences). Replaces `.len() == 0` with `.is_empty()` and `.len() > 0` with `!x.is_empty()`. Verification.rs already covered by #827. Also includes a few related simplifications in link_store.rs: - Drops duplicate `is_empty() || .len() == 0` checks in link_add_key and link_remove_key (the OR-clauses were logically redundant) - Removes unreachable `is_empty()` check on `Option<&[u8; 24]>` — a fixed-size 24-byte array can never be empty - Simplifies `data_bytes.is_some() && data_bytes.as_ref().unwrap().len() > 0` in store/account/message.rs to `data_bytes.as_ref().is_some_and(|b| !b.is_empty())` Adds 6 regression tests in link_store_test.rs covering the error branches in link_add_key / link_remove_key (`"targetId provided without type"`, `"link type invalid"`) which had no prior direct coverage. Supersedes #592. Co-Authored-By: Claude Sonnet 4.6 --- src/consensus/consensus.rs | 4 +- src/consensus/malachite/read_sync.rs | 2 +- src/core/types.rs | 2 +- src/core/validations/message.rs | 10 +- src/mempool/block_receiver.rs | 4 +- src/network/gossip.rs | 4 +- src/network/http_server.rs | 2 +- src/perf/perftest.rs | 8 +- .../store/account/block_event_store.rs | 3 +- src/storage/store/account/cast_store.rs | 4 +- src/storage/store/account/event.rs | 2 +- src/storage/store/account/link_store.rs | 20 +-- src/storage/store/account/link_store_test.rs | 114 ++++++++++++++++++ src/storage/store/account/message.rs | 6 +- .../store/account/onchain_event_store.rs | 4 +- src/storage/store/account/reaction_store.rs | 2 +- .../store/account/username_proof_store.rs | 6 +- src/storage/store/block.rs | 2 +- src/storage/store/engine_tests.rs | 6 +- src/storage/store/shard.rs | 2 +- src/storage/trie/trie_node.rs | 4 +- 21 files changed, 159 insertions(+), 52 deletions(-) diff --git a/src/consensus/consensus.rs b/src/consensus/consensus.rs index 8e9cbbb87..8119f215f 100644 --- a/src/consensus/consensus.rs +++ b/src/consensus/consensus.rs @@ -100,12 +100,12 @@ impl Config { pub fn get_validator_set_config(&self, shard_id: u32) -> Vec { if let Some(sets) = &self.validator_sets { - assert!(sets.len() > 0); + assert!(!sets.is_empty()); return sets.to_vec(); } if let Some(addresses) = &self.validator_addresses { - assert!(addresses.len() > 0); + assert!(!addresses.is_empty()); return vec![ValidatorSetConfig { effective_at: 0, validator_public_keys: addresses.clone(), diff --git a/src/consensus/malachite/read_sync.rs b/src/consensus/malachite/read_sync.rs index f70158523..78814d34b 100644 --- a/src/consensus/malachite/read_sync.rs +++ b/src/consensus/malachite/read_sync.rs @@ -116,7 +116,7 @@ impl State { return false; } - if self.sync.peers.len() == 0 { + if self.sync.peers.is_empty() { return false; } diff --git a/src/core/types.rs b/src/core/types.rs index 6b95ff482..0291bbd2a 100644 --- a/src/core/types.rs +++ b/src/core/types.rs @@ -521,7 +521,7 @@ impl informalsystems_malachitebft_core_types::Context for SnapchainValidatorCont height: Self::Height, round: Round, ) -> &'a Self::Validator { - assert!(validator_set.validators.len() > 0); + assert!(!validator_set.validators.is_empty()); assert!(round != Round::Nil && round.as_i64() >= 0); let proposer_index = { diff --git a/src/core/validations/message.rs b/src/core/validations/message.rs index 58a15b6a2..3f4c6f858 100644 --- a/src/core/validations/message.rs +++ b/src/core/validations/message.rs @@ -36,7 +36,7 @@ fn validate_bytes_as_string( max_length: u64, required: bool, ) -> Result<(), ValidationError> { - if required && byte_array.len() == 0 { + if required && byte_array.is_empty() { return Err(ValidationError::MissingString); } if byte_array.len() as u64 > max_length { @@ -95,7 +95,7 @@ pub fn validate_message( let message_data; if message.data_bytes.is_some() { data_bytes = message.data_bytes.as_ref().unwrap().clone(); - if data_bytes.len() == 0 { + if data_bytes.is_empty() { return Err(ValidationError::MissingData); } match MessageData::decode(message.data_bytes.as_ref().unwrap().as_slice()) { @@ -255,7 +255,7 @@ fn validate_signature( return Err(ValidationError::InvalidSignatureScheme); } - if signature.len() == 0 { + if signature.is_empty() { return Err(ValidationError::MissingSignature); } @@ -279,7 +279,7 @@ pub fn validate_message_hash( return Err(ValidationError::InvalidHashScheme); } - if data_bytes.len() == 0 { + if data_bytes.is_empty() { return Err(ValidationError::MissingData); } @@ -291,7 +291,7 @@ pub fn validate_message_hash( } pub fn validate_fname(input: &String) -> Result<(), ValidationError> { - if input.len() == 0 { + if input.is_empty() { return Err(ValidationError::FnameIsMissing); } diff --git a/src/mempool/block_receiver.rs b/src/mempool/block_receiver.rs index 6e283668c..7ab6d510c 100644 --- a/src/mempool/block_receiver.rs +++ b/src/mempool/block_receiver.rs @@ -54,7 +54,7 @@ pub struct BlockReceiver { impl BlockReceiver { fn validate_block_events(&self, block: &Block) -> bool { - if block.events.len() == 0 { + if block.events.is_empty() { return true; } @@ -188,7 +188,7 @@ impl BlockReceiver { height = block.header.as_ref().unwrap().height.unwrap().block_number, "Received block" ); - if block.events.len() == 0 { + if block.events.is_empty() { continue; } // The db is the source of truth, it's possible to read this out of the events_rx channel but delivery over that channel is not reliable (it's a broadcast channel) we may not have the most up to date state. diff --git a/src/network/gossip.rs b/src/network/gossip.rs index 5586e1e3d..af69bc340 100644 --- a/src/network/gossip.rs +++ b/src/network/gossip.rs @@ -370,7 +370,7 @@ impl SnapchainGossip { fc_network: FarcasterNetwork, config: &Config, ) -> Result { - if config.announce_rpc_address.len() > 0 { + if !config.announce_rpc_address.is_empty() { return Ok(config.announce_rpc_address.clone()); } @@ -387,7 +387,7 @@ impl SnapchainGossip { } async fn get_announce_gossip_address(fc_network: FarcasterNetwork, config: &Config) -> String { - if config.announce_address.len() > 0 { + if !config.announce_address.is_empty() { return config.announce_address.clone(); } diff --git a/src/network/http_server.rs b/src/network/http_server.rs index 2a1013a4e..395324999 100644 --- a/src/network/http_server.rs +++ b/src/network/http_server.rs @@ -71,7 +71,7 @@ mod serdebase64opt { pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result>, D::Error> { let base64 = String::deserialize(d)?.replace(" ", "+"); - if base64.len() == 0 { + if base64.is_empty() { Ok(None) } else { let decoded = BASE64_STANDARD diff --git a/src/perf/perftest.rs b/src/perf/perftest.rs index 54e4483e6..aad883de7 100644 --- a/src/perf/perftest.rs +++ b/src/perf/perftest.rs @@ -224,10 +224,10 @@ pub async fn run() -> Result<(), Box> { } } time = stats_calculation_timer.tick() => { - let avg_time_to_confirmation = if time_to_confirmation.len() > 0 {time_to_confirmation.iter().sum::() as f64 / time_to_confirmation.len() as f64} else {0f64}; - let max_time_to_confirmation = if time_to_confirmation.len() > 0 {time_to_confirmation.clone().into_iter().max().unwrap()} else {0}; - let avg_block_time = if block_times.len() > 0 {block_times.iter().sum::() as f64 / block_times.len() as f64} else {0f64}; - let max_block_time = if block_times.len() > 0 {block_times.clone().into_iter().max().unwrap()} else {0}; + let avg_time_to_confirmation = if !time_to_confirmation.is_empty() {time_to_confirmation.iter().sum::() as f64 / time_to_confirmation.len() as f64} else {0f64}; + let max_time_to_confirmation = if !time_to_confirmation.is_empty() {time_to_confirmation.clone().into_iter().max().unwrap()} else {0}; + let avg_block_time = if !block_times.is_empty() {block_times.iter().sum::() as f64 / block_times.len() as f64} else {0f64}; + let max_block_time = if !block_times.is_empty() {block_times.clone().into_iter().max().unwrap()} else {0}; let time_elapsed = time.duration_since(start).as_secs(); let confirmed_msgs_per_sec = num_messages_confirmed as f64 / cfg.stats_calculation_interval.as_secs_f64(); let submitted_msgs_per_sec = num_messages_submitted as f64 / cfg.stats_calculation_interval.as_secs_f64(); diff --git a/src/storage/store/account/block_event_store.rs b/src/storage/store/account/block_event_store.rs index 23955f2cf..aa7a4204e 100644 --- a/src/storage/store/account/block_event_store.rs +++ b/src/storage/store/account/block_event_store.rs @@ -5,6 +5,7 @@ use crate::storage::db::{PageOptions, RocksDB, RocksDbTransactionBatch, RocksdbE use prost::Message; use std::sync::Arc; use thiserror::Error; +use tracing::error; #[derive(Error, Debug)] pub enum BlockEventStorageError { @@ -79,7 +80,7 @@ fn get_block_page_by_prefix( ) .map_err(|_| BlockEventStorageError::TooManyBlocksInResult)?; // TODO: Return the right error - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key) } else { None diff --git a/src/storage/store/account/cast_store.rs b/src/storage/store/account/cast_store.rs index 425302d00..3e10e697c 100644 --- a/src/storage/store/account/cast_store.rs +++ b/src/storage/store/account/cast_store.rs @@ -479,7 +479,7 @@ impl CastStore { )?; let messages = get_many_messages(store.db().borrow(), message_keys)?; - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key.to_vec()) } else { None @@ -525,7 +525,7 @@ impl CastStore { )?; let messages_bytes = get_many_messages(store.db().borrow(), message_keys)?; - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key.to_vec()) } else { None diff --git a/src/storage/store/account/event.rs b/src/storage/store/account/event.rs index 20e827523..64035f506 100644 --- a/src/storage/store/account/event.rs +++ b/src/storage/store/account/event.rs @@ -200,7 +200,7 @@ impl HubEventStorageExt for HubEvent { Ok(EventsPage { events, - next_page_token: if last_key.len() > 0 { + next_page_token: if !last_key.is_empty() { Some(last_key) } else { None diff --git a/src/storage/store/account/link_store.rs b/src/storage/store/account/link_store.rs index c6dd2ae75..7212ddf7e 100644 --- a/src/storage/store/account/link_store.rs +++ b/src/storage/store/account/link_store.rs @@ -177,7 +177,7 @@ impl LinkStore { )?; let messages = get_many_messages(store.db().borrow(), message_keys)?; - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key.to_vec()) } else { None @@ -244,17 +244,13 @@ impl LinkStore { /// * `link_body` - body of link that contains type of link created and target ID of the object /// being reacted to fn link_add_key(fid: u64, link_body: &LinkBody) -> Result, HubError> { - if link_body.target.is_some() - && (link_body.r#type.is_empty() || link_body.r#type.len() == 0) - { + if link_body.target.is_some() && link_body.r#type.is_empty() { return Err(HubError::validation_failure( "targetId provided without type", )); } - if !link_body.r#type.is_empty() - && (link_body.r#type.len() > Self::LINK_TYPE_BYTE_SIZE || link_body.r#type.len() == 0) - { + if !link_body.r#type.is_empty() && link_body.r#type.len() > Self::LINK_TYPE_BYTE_SIZE { return Err(HubError::validation_failure( "link type invalid - non-empty link type found with invalid length", )); @@ -291,17 +287,13 @@ impl LinkStore { /// * `link_body` - body of link that contains type of link created and target ID of the object /// being reacted to fn link_remove_key(fid: u64, link_body: &LinkBody) -> Result, HubError> { - if link_body.target.is_some() - && (link_body.r#type.is_empty() || link_body.r#type.len() == 0) - { + if link_body.target.is_some() && link_body.r#type.is_empty() { return Err(HubError::validation_failure( "targetID provided without type", )); } - if !link_body.r#type.is_empty() - && (link_body.r#type.len() > Self::LINK_TYPE_BYTE_SIZE || link_body.r#type.len() == 0) - { + if !link_body.r#type.is_empty() && link_body.r#type.len() > Self::LINK_TYPE_BYTE_SIZE { return Err(HubError::validation_failure( "link type invalid - non-empty link type found with invalid length", )); @@ -375,7 +367,7 @@ impl LinkStore { fid: u64, ts_hash: Option<&[u8; TS_HASH_LENGTH]>, ) -> Result, HubError> { - if fid != 0 && (ts_hash.is_none() || ts_hash.is_some_and(|tsh| tsh.len() == 0)) { + if fid != 0 && ts_hash.is_none() { return Err(HubError::validation_failure( "fid provided without timestamp hash", )); diff --git a/src/storage/store/account/link_store_test.rs b/src/storage/store/account/link_store_test.rs index fc9e03eb9..fa564cfc5 100644 --- a/src/storage/store/account/link_store_test.rs +++ b/src/storage/store/account/link_store_test.rs @@ -2144,4 +2144,118 @@ mod tests { .unwrap(); assert_eq!(result3, add3); } + + // Regression tests for link_add_key / link_remove_key error branches. + // These cover the paths simplified when `.len() == 0 || .is_empty()` duplication was removed. + + fn make_link_add_with(fid: u64, link_type: &str, target: Option) -> message::Message { + let mut msg = messages_factory::links::create_link_add(fid, link_type, 0, None, None); + if let Some(data) = msg.data.as_mut() { + if let Some(message::message_data::Body::LinkBody(body)) = data.body.as_mut() { + body.r#type = link_type.to_string(); + body.target = target; + } + } + msg + } + + fn make_link_remove_with( + fid: u64, + link_type: &str, + target: Option, + ) -> message::Message { + let mut msg = messages_factory::links::create_link_remove(fid, link_type, 0, None, None); + if let Some(data) = msg.data.as_mut() { + if let Some(message::message_data::Body::LinkBody(body)) = data.body.as_mut() { + body.r#type = link_type.to_string(); + body.target = target; + } + } + msg + } + + #[test] + fn test_make_add_key_rejects_empty_type_with_target() { + let msg = make_link_add_with(FID_FOR_TEST, "", Some(Target::TargetFid(TARGET_FID))); + let result = LinkStore::make_add_key(&msg); + assert!(result.is_err(), "empty type with target should be rejected"); + assert!( + result + .unwrap_err() + .message + .contains("targetId provided without type"), + "expected targetId-without-type error" + ); + } + + #[test] + fn test_make_remove_key_rejects_empty_type_with_target() { + let msg = make_link_remove_with(FID_FOR_TEST, "", Some(Target::TargetFid(TARGET_FID))); + let result = LinkStore::make_remove_key(&msg); + assert!(result.is_err(), "empty type with target should be rejected"); + assert!( + result + .unwrap_err() + .message + .contains("targetID provided without type"), + "expected targetID-without-type error" + ); + } + + #[test] + fn test_make_add_key_rejects_overlong_type() { + // LINK_TYPE_BYTE_SIZE is 8; "xxxxxxxxx" is 9 bytes + let msg = make_link_add_with( + FID_FOR_TEST, + "xxxxxxxxx", + Some(Target::TargetFid(TARGET_FID)), + ); + let result = LinkStore::make_add_key(&msg); + assert!( + result.is_err(), + "type longer than 8 bytes should be rejected" + ); + assert!( + result.unwrap_err().message.contains("link type invalid"), + "expected link-type-invalid error" + ); + } + + #[test] + fn test_make_remove_key_rejects_overlong_type() { + let msg = make_link_remove_with( + FID_FOR_TEST, + "xxxxxxxxx", + Some(Target::TargetFid(TARGET_FID)), + ); + let result = LinkStore::make_remove_key(&msg); + assert!( + result.is_err(), + "type longer than 8 bytes should be rejected" + ); + assert!( + result.unwrap_err().message.contains("link type invalid"), + "expected link-type-invalid error" + ); + } + + #[test] + fn test_make_add_key_accepts_valid_type() { + let msg = make_link_add_with( + FID_FOR_TEST, + LINK_TYPE_FOLLOW, + Some(Target::TargetFid(TARGET_FID)), + ); + assert!(LinkStore::make_add_key(&msg).is_ok()); + } + + #[test] + fn test_make_remove_key_accepts_valid_type() { + let msg = make_link_remove_with( + FID_FOR_TEST, + LINK_TYPE_FOLLOW, + Some(Target::TargetFid(TARGET_FID)), + ); + assert!(LinkStore::make_remove_key(&msg).is_ok()); + } } diff --git a/src/storage/store/account/message.rs b/src/storage/store/account/message.rs index b0269d53f..21132aa76 100644 --- a/src/storage/store/account/message.rs +++ b/src/storage/store/account/message.rs @@ -273,7 +273,7 @@ where }, )?; - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key.to_vec()) } else { None @@ -287,7 +287,7 @@ where #[inline] pub fn message_encode(message: &MessageProto) -> Vec { - if message.data_bytes.is_some() && message.data_bytes.as_ref().unwrap().len() > 0 { + if message.data_bytes.as_ref().is_some_and(|b| !b.is_empty()) { // Clone the message let mut cloned = message.clone(); cloned.data = None; @@ -300,7 +300,7 @@ pub fn message_encode(message: &MessageProto) -> Vec { #[inline] pub fn message_bytes_decode(msg: &mut MessageProto) { - if msg.data_bytes.is_some() && msg.data_bytes.as_ref().unwrap().len() > 0 { + if msg.data_bytes.as_ref().is_some_and(|b| !b.is_empty()) { if let Ok(msg_data) = MessageData::decode(msg.data_bytes.as_ref().unwrap().as_slice()) { msg.data = Some(msg_data); } else { diff --git a/src/storage/store/account/onchain_event_store.rs b/src/storage/store/account/onchain_event_store.rs index 3a7c981e5..1e72c5dbd 100644 --- a/src/storage/store/account/onchain_event_store.rs +++ b/src/storage/store/account/onchain_event_store.rs @@ -295,7 +295,7 @@ pub fn get_onchain_events( }, ) .map_err(|e| OnchainEventStorageError::HubError(e))?; // TODO: Return the right error - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key) } else { None @@ -344,7 +344,7 @@ where }, ) .map_err(|e| OnchainEventStorageError::HubError(e))?; // TODO: Return the right error - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key) } else { None diff --git a/src/storage/store/account/reaction_store.rs b/src/storage/store/account/reaction_store.rs index 52e224eb8..78bc4f7bc 100644 --- a/src/storage/store/account/reaction_store.rs +++ b/src/storage/store/account/reaction_store.rs @@ -429,7 +429,7 @@ impl ReactionStore { )?; let messages = get_many_messages(store.db().borrow(), message_keys)?; - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key.to_vec()) } else { None diff --git a/src/storage/store/account/username_proof_store.rs b/src/storage/store/account/username_proof_store.rs index ec99f7084..810778dd3 100644 --- a/src/storage/store/account/username_proof_store.rs +++ b/src/storage/store/account/username_proof_store.rs @@ -128,7 +128,7 @@ impl StoreDef for UsernameProofStoreDef { let data = message.data.as_ref().unwrap(); if let Some(Body::UsernameProofBody(body)) = &data.body { - if body.name.len() == 0 { + if body.name.is_empty() { return Err(HubError { code: "bad_request.invalid_param".to_string(), message: "name empty".to_string(), @@ -165,7 +165,7 @@ impl StoreDef for UsernameProofStoreDef { let data = message.data.as_ref().unwrap(); if let Some(Body::UsernameProofBody(body)) = &data.body { - if body.name.len() == 0 { + if body.name.is_empty() { return Err(HubError { code: "bad_request.invalid_param".to_string(), message: "name empty".to_string(), @@ -303,7 +303,7 @@ impl StoreDef for UsernameProofStoreDef { _ => None, }; - let (deleted_proof_body, deleted_message) = if merge_conflicts.len() > 0 { + let (deleted_proof_body, deleted_message) = if !merge_conflicts.is_empty() { match &merge_conflicts[0].data { Some(message_data) => match &message_data.body { Some(Body::UsernameProofBody(username_proof_body)) => ( diff --git a/src/storage/store/block.rs b/src/storage/store/block.rs index 74fc336a7..242f2d605 100644 --- a/src/storage/store/block.rs +++ b/src/storage/store/block.rs @@ -96,7 +96,7 @@ fn get_block_page_by_prefix( ) .map_err(|_| BlockStorageError::TooManyBlocksInResult)?; // TODO: Return the right error - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key) } else { None diff --git a/src/storage/store/engine_tests.rs b/src/storage/store/engine_tests.rs index e783fe45f..45f12680f 100644 --- a/src/storage/store/engine_tests.rs +++ b/src/storage/store/engine_tests.rs @@ -1082,7 +1082,7 @@ mod tests { .unwrap(); let updated_shard_root = engine.get_stores().trie.root_hash().unwrap(); // Account root is not empty after a message is committed - assert_eq!(updated_account_root.len() > 0, true); + assert!(!updated_account_root.is_empty()); assert_ne!(updated_shard_root, shard_root); let another_fid_event = events_factory::create_onchain_event(FID_FOR_TEST + 1); @@ -1100,7 +1100,7 @@ mod tests { .unwrap(); let latest_shard_root = engine.get_stores().trie.root_hash().unwrap(); // Only the account root for the new fid and the shard root is updated, original fid account root remains the same - assert_eq!(account_root_another_fid.len() > 0, true); + assert!(!account_root_another_fid.is_empty()); assert_eq!(account_root_original_fid, updated_account_root); assert_ne!(latest_shard_root, updated_shard_root); } @@ -1316,7 +1316,7 @@ mod tests { let result = engine.simulate_bulk_messages(&messages_batch); assert!( - result.len() == 0, + result.is_empty(), "Simulating an empty batch should succeed" ); diff --git a/src/storage/store/shard.rs b/src/storage/store/shard.rs index d3390a27b..cd82a3781 100644 --- a/src/storage/store/shard.rs +++ b/src/storage/store/shard.rs @@ -101,7 +101,7 @@ fn get_shard_page_by_prefix( ) .map_err(|e| ShardStorageError::HubError(e))?; - let next_page_token = if last_key.len() > 0 { + let next_page_token = if !last_key.is_empty() { Some(last_key) } else { None diff --git a/src/storage/trie/trie_node.rs b/src/storage/trie/trie_node.rs index 2e638979d..6f05f8e0d 100644 --- a/src/storage/trie/trie_node.rs +++ b/src/storage/trie/trie_node.rs @@ -274,7 +274,7 @@ impl TrieNode { mut keys: Vec>, current_index: usize, ) -> Result, TrieError> { - if keys.len() == 0 { + if keys.is_empty() { return Err(TrieError::NoKeysToInsert); } @@ -636,7 +636,7 @@ impl TrieNode { child_hashes: &mut HashMap>, prefix: &[u8], ) -> Result<(), TrieError> { - if prefix.len() > 0 { + if !prefix.is_empty() { let char = prefix[prefix.len() - 1]; let hash = self.hash(); From 0b8d8ed931615f3eec510ee6333bbb30ca138af3 Mon Sep 17 00:00:00 2001 From: Manan Date: Fri, 24 Apr 2026 17:22:34 -0700 Subject: [PATCH 2/2] fix: drop stale tracing::error import + standardize targetId casing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two issues caught by CI and Copilot review: 1. block_event_store.rs no longer needs `use tracing::error;` — the import was carried over from an older revision when the file's only call site used the macro. Rust 1.95 + -Dwarnings turns this unused import into a hard CI failure. 2. link_store.rs's link_remove_key error message was "targetID …" while link_add_key (and other stores like reaction_store) use "targetId …". Standardize on the lowercase 'd' variant; update the matching test assertion. Co-Authored-By: Claude Sonnet 4.6 --- src/storage/store/account/block_event_store.rs | 1 - src/storage/store/account/link_store.rs | 2 +- src/storage/store/account/link_store_test.rs | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/storage/store/account/block_event_store.rs b/src/storage/store/account/block_event_store.rs index aa7a4204e..d5f5a8e53 100644 --- a/src/storage/store/account/block_event_store.rs +++ b/src/storage/store/account/block_event_store.rs @@ -5,7 +5,6 @@ use crate::storage::db::{PageOptions, RocksDB, RocksDbTransactionBatch, RocksdbE use prost::Message; use std::sync::Arc; use thiserror::Error; -use tracing::error; #[derive(Error, Debug)] pub enum BlockEventStorageError { diff --git a/src/storage/store/account/link_store.rs b/src/storage/store/account/link_store.rs index 7212ddf7e..afbbebecc 100644 --- a/src/storage/store/account/link_store.rs +++ b/src/storage/store/account/link_store.rs @@ -289,7 +289,7 @@ impl LinkStore { fn link_remove_key(fid: u64, link_body: &LinkBody) -> Result, HubError> { if link_body.target.is_some() && link_body.r#type.is_empty() { return Err(HubError::validation_failure( - "targetID provided without type", + "targetId provided without type", )); } diff --git a/src/storage/store/account/link_store_test.rs b/src/storage/store/account/link_store_test.rs index fa564cfc5..5696a8f33 100644 --- a/src/storage/store/account/link_store_test.rs +++ b/src/storage/store/account/link_store_test.rs @@ -2197,8 +2197,8 @@ mod tests { result .unwrap_err() .message - .contains("targetID provided without type"), - "expected targetID-without-type error" + .contains("targetId provided without type"), + "expected targetId-without-type error" ); }