diff --git a/services/identity/src/client_service.rs b/services/identity/src/client_service.rs --- a/services/identity/src/client_service.rs +++ b/services/identity/src/client_service.rs @@ -1099,7 +1099,7 @@ tonic::Status::invalid_argument("invalid device list update") } e => { - error!("Encountered an unexpected error: {}", e); + error!("DB Error: Encountered an unexpected error: {}", e); tonic::Status::failed_precondition("unexpected error") } } diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs --- a/services/identity/src/database.rs +++ b/services/identity/src/database.rs @@ -474,7 +474,10 @@ Ok(out) } Err(e) => { - error!("DynamoDB client failed to delete user {}", user_id); + error!( + "DB Error: DynamoDB client failed to delete user {}", + user_id + ); Err(Error::AwsSdk(e.into())) } } @@ -582,7 +585,7 @@ } Err(e) => { error!( - "DynamoDB client failed to get user from {} {}: {}", + "DB Error: DynamoDB client failed to get user from {} {}: {}", attribute_name, user_info, e ); Err(Error::AwsSdk(e.into())) @@ -670,7 +673,7 @@ } Err(e) => { error!( - "DynamoDB client failed to get registration data for user {}: {}", + "DB Error: DynamoDB client failed to get registration data for user {}: {}", username, e ); Err(e) @@ -726,7 +729,7 @@ .map(Identifier::try_from) .transpose() .map_err(|e| { - error!(user_id, "Database item is missing an identifier"); + error!(user_id, "DB Error: Database item is missing an identifier"); e }) } @@ -961,7 +964,7 @@ Ok(out) } Err(e) => { - error!("DynamoDB client failed to delete username {} from reserved usernames table", username); + error!("DB Error: DynamoDB client failed to delete username {} from reserved usernames table", username); Err(Error::AwsSdk(e.into())) } } @@ -1042,7 +1045,7 @@ attribute = attribute_name, value = ?attribute_value, error_type = "IncorrectType", - "Unexpected attribute type when parsing map attribute" + "DB Error: Unexpected attribute type when parsing map attribute" ); Err(DBItemError::new( attribute_name.to_string(), @@ -1054,7 +1057,7 @@ error!( attribute = attribute_name, error_type = "Missing", - "Attribute is missing" + "DB Error: Attribute is missing" ); Err(DBItemError::new( attribute_name.to_string(), diff --git a/services/identity/src/database/device_list.rs b/services/identity/src/database/device_list.rs --- a/services/identity/src/database/device_list.rs +++ b/services/identity/src/database/device_list.rs @@ -86,7 +86,7 @@ if !is_valid_olm_key(&upload.content_prekey) || !is_valid_olm_key(&upload.notif_prekey) { - error!("Invalid prekey format"); + error!("Device List DB Error: Invalid prekey format"); return Err(Error::InvalidFormat); } let device_row = Self { @@ -429,7 +429,10 @@ .send() .await .map_err(|e| { - error!("Failed to get current devices: {:?}", e); + error!( + "Device List DB Error: Failed to get current devices: {:?}", + e + ); Error::AwsSdk(e.into()) })?; @@ -473,7 +476,7 @@ .send() .await .map_err(|e| { - error!("Failed to query device list updates by index: {:?}", e); + error!("Device List DB Error: Failed to query device list updates by index: {:?}", e); Error::AwsSdk(e.into()) })? .items @@ -483,7 +486,7 @@ .send() .await .map_err(|e| { - error!("Failed to query device list updates (all): {:?}", e); + error!("Device List DB Error: Failed to query device list updates (all): {:?}", e); Error::AwsSdk(e.into()) })? .items @@ -523,7 +526,7 @@ if !is_valid_olm_key(&content_prekey.prekey) || !is_valid_olm_key(¬if_prekey.prekey) { - error!("Invalid prekey format"); + error!("Device List DB Error: Invalid prekey format"); return Err(Error::InvalidFormat); } self @@ -547,7 +550,10 @@ .send() .await .map_err(|e| { - error!("Failed to update device prekeys: {:?}", e); + error!( + "Device List DB Error: Failed to update device prekeys: {:?}", + e + ); Error::AwsSdk(e.into()) })?; @@ -572,7 +578,10 @@ .send() .await .map_err(|e| { - error!("Failed to check if device exists: {:?}", e); + error!( + "Device List DB Error: Failed to check if device exists: {:?}", + e + ); Error::AwsSdk(e.into()) })?; @@ -594,7 +603,7 @@ .send() .await .map_err(|e| { - error!("Failed to fetch device data: {:?}", e); + error!("Device List DB Error: Failed to fetch device data: {:?}", e); Error::AwsSdk(e.into()) })?; @@ -617,7 +626,7 @@ .as_ref() .and_then(|list| list.device_ids.first()) else { - error!(user_id, "Device list is empty. Cannot fetch primary device"); + error!(user_id, "Device List DB Error: Device list is empty. Cannot fetch primary device"); return Err(Error::DeviceList(DeviceListError::DeviceNotFound)); }; @@ -626,7 +635,7 @@ .await? .ok_or_else(|| { error!( - "Corrupt database. Missing primary device data for user {}", + "Device List DB Error: Corrupt database. Missing primary device data for user {}", user_id ); Error::MissingItem @@ -661,7 +670,10 @@ .send() .await .map_err(|e| { - error!("Failed to update device login time: {:?}", e); + error!( + "Device List DB Error: Failed to update device login time: {:?}", + e + ); Error::AwsSdk(e.into()) })?; @@ -691,7 +703,7 @@ .send() .await .map_err(|e| { - error!("Failed to query device list updates by index: {:?}", e); + error!("Device List DB Error: Failed to query device list updates by index: {:?}", e); Error::AwsSdk(e.into()) })? .items @@ -731,7 +743,7 @@ .send() .await .map_err(|e| { - error!("Failed to put device data: {:?}", e); + error!("Device List DB Error: Failed to put device data: {:?}", e); Error::AwsSdk(e.into()) })?; @@ -977,7 +989,10 @@ Error::DeviceList(DeviceListError::ConcurrentUpdateError) } other => { - error!("Device list update transaction failed: {:?}", other); + error!( + "Device List DB Error: Device list update transaction failed: {:?}", + other + ); Error::AwsSdk(other) } })?; @@ -1011,7 +1026,7 @@ .send() .await .map_err(|e| { - error!("Failed to list user's items in devices table: {:?}", e); + error!("Device List DB Error: Failed to list user's items in devices table: {:?}", e); Error::AwsSdk(e.into()) })? .items @@ -1034,7 +1049,7 @@ .send() .await .map_err(|e| { - error!("Failed to batch delete items from devices table: {:?}", e); + error!("Device List DB Error: Failed to batch delete items from devices table: {:?}", e); Error::AwsSdk(e.into()) })?; } @@ -1061,7 +1076,7 @@ .send() .await .map_err(|e| { - error!("Failed to get user's device list timestamp: {:?}", e); + error!("Device List DB Error: Failed to get user's device list timestamp: {:?}", e); Error::AwsSdk(e.into()) })?; @@ -1157,7 +1172,10 @@ devices_data: &[DeviceRow], ) { if !verify_device_list_match(list, devices_data) { - error!("Found corrupt device list for user (userID={})!", user_id); + error!( + "Device List DB Error: Found corrupt device list for user (userID={})!", + user_id + ); return; } @@ -1184,7 +1202,7 @@ list.iter().position(|id| id == &primary_device.device_id) else { error!( - "Primary device not found in device list (userID={})", + "Device List DB Error: Primary device not found in device list (userID={})", user_id ); return; @@ -1200,7 +1218,7 @@ devices_data: &[DeviceRow], ) -> bool { if list.len() != devices_data.len() { - error!("Device list length mismatch!"); + error!("Device List DB Error: Device list length mismatch!"); return false; } @@ -1216,7 +1234,7 @@ .next() { error!( - "Device list is corrupt (unknown deviceID={})", + "Device List DB Error: Device list is corrupt (unknown deviceID={})", corrupt_device_id ); return false; diff --git a/services/identity/src/database/farcaster.rs b/services/identity/src/database/farcaster.rs --- a/services/identity/src/database/farcaster.rs +++ b/services/identity/src/database/farcaster.rs @@ -42,7 +42,10 @@ .send() .await .map_err(|e| { - error!("Failed to query users by farcasterID: {:?}", e); + error!( + "Farcaster DB Error: Failed to query users by farcasterID: {:?}", + e + ); Error::AwsSdk(e.into()) })? .items diff --git a/services/identity/src/database/one_time_keys.rs b/services/identity/src/database/one_time_keys.rs --- a/services/identity/src/database/one_time_keys.rs +++ b/services/identity/src/database/one_time_keys.rs @@ -145,7 +145,7 @@ info!("Encountered transaction conflict while retrieving one-time key - retrying"); } else { error!( - "One-time key retrieval transaction failed: {:?}", + "One-time Key DB Error: One-time key retrieval transaction failed: {:?}", dynamo_db_error ); return Err(Error::AwsSdk(dynamo_db_error)); @@ -197,7 +197,7 @@ if let Some(limit) = num_keys { if otk_rows.len() != limit { - error!("There are fewer one-time keys than the number requested"); + error!("One-time Key DB Error: There are fewer one-time keys than the number requested"); return Err(Error::NotEnoughOneTimeKeys); } } @@ -325,7 +325,7 @@ info!("Encountered transaction conflict while uploading one-time keys - retrying"); } else { error!( - "One-time key upload transaction failed: {:?}", + "One-time Key DB Error: One-time key upload transaction failed: {:?}", dynamo_db_error ); return Err(Error::AwsSdk(dynamo_db_error)); @@ -367,7 +367,10 @@ .send() .await .map_err(|e| { - error!("Failed to get user's OTK count: {:?}", e); + error!( + "One-time Key DB Error: Failed to get user's OTK count: {:?}", + e + ); Error::AwsSdk(e.into()) })?; diff --git a/services/identity/src/database/token.rs b/services/identity/src/database/token.rs --- a/services/identity/src/database/token.rs +++ b/services/identity/src/database/token.rs @@ -72,7 +72,7 @@ } Err(e) => { error!( - "DynamoDB client failed to get token for user {} with signing public key {}: {}", + "Token DB Error: DynamoDB client failed to get token for user {} with signing public key {}: {}", user_id, signing_public_key, e ); Err(Error::AwsSdk(e.into())) @@ -187,7 +187,10 @@ .send() .await .map_err(|e| { - error!("Failed to list user's items in tokens table: {:?}", e); + error!( + "Token DB Error: Failed to list user's items in tokens table: {:?}", + e + ); Error::AwsSdk(e.into()) })? .items diff --git a/services/identity/src/grpc_services/authenticated.rs b/services/identity/src/grpc_services/authenticated.rs --- a/services/identity/src/grpc_services/authenticated.rs +++ b/services/identity/src/grpc_services/authenticated.rs @@ -504,13 +504,16 @@ warn!(user_id, "User has no device list, skipping!"); } Ok((user_id, Err(err))) => { - error!(user_id, "Failed fetching device list: {err}"); + error!( + user_id, + "gRPC Services Error: Failed fetching device list: {err}" + ); // abort fetching other users fetch_tasks.abort_all(); return Err(handle_db_error(err)); } Err(join_error) => { - error!("Failed to join device list task: {join_error}"); + error!("gRPC Services Error: Failed to join device list task: {join_error}"); fetch_tasks.abort_all(); return Err(Status::aborted("unexpected error")); } @@ -562,7 +565,7 @@ .map_err(handle_db_error)?; if get_farcaster_users_response.len() > 1 { - error!("multiple users associated with the same Farcaster ID"); + error!("gRPC Services Error: multiple users associated with the same Farcaster ID"); return Err(Status::failed_precondition("cannot link Farcaster ID")); } @@ -650,7 +653,10 @@ /// Serialize (and sign in the future) a [`RawDeviceList`] fn try_from_raw(raw: RawDeviceList) -> Result { let stringified_list = serde_json::to_string(&raw).map_err(|err| { - error!("Failed to serialize raw device list: {}", err); + error!( + "gRPC Services Error: Failed to serialize raw device list: {}", + err + ); tonic::Status::failed_precondition("unexpected error") })?; @@ -672,7 +678,10 @@ /// Serializes the signed device list to a JSON string fn as_json_string(&self) -> Result { serde_json::to_string(self).map_err(|err| { - error!("Failed to serialize device list updates: {}", err); + error!( + "gRPC Services Error: Failed to serialize device list updates: {}", + err + ); tonic::Status::failed_precondition("unexpected error") }) } @@ -697,7 +706,7 @@ } = signed_list.as_raw()?; let timestamp = DateTime::::from_utc_timestamp_millis(raw_timestamp) .ok_or_else(|| { - error!("Failed to parse RawDeviceList timestamp!"); + error!("gRPC Services Error: Failed to parse RawDeviceList timestamp!"); tonic::Status::invalid_argument("invalid timestamp") })?; Ok(DeviceListUpdate::new(devices, timestamp)) diff --git a/services/identity/src/siwe.rs b/services/identity/src/siwe.rs --- a/services/identity/src/siwe.rs +++ b/services/identity/src/siwe.rs @@ -19,25 +19,25 @@ siwe_signature: &str, ) -> Result { let siwe_message: Message = siwe_message.parse().map_err(|e| { - error!("Failed to parse SIWE message: {}", e); + error!("SIWE Error: Failed to parse SIWE message: {}", e); Status::invalid_argument("invalid message") })?; let decoded_signature = hex::decode(siwe_signature.trim_start_matches("0x")) .map_err(|e| { - error!("Failed to decode SIWE signature: {}", e); + error!("SIWE Error: Failed to decode SIWE signature: {}", e); Status::invalid_argument("invalid signature") })?; let signature = decoded_signature.try_into().map_err(|e| { - error!("Conversion to SIWE signature failed: {:?}", e); + error!("SIWE Error: Conversion to SIWE signature failed: {:?}", e); Status::invalid_argument("invalid message") })?; siwe_message .verify(signature, None, None, Some(&Utc::now())) .map_err(|e| { - error!("Signature verification failed: {}", e); + error!("SIWE Error: Signature verification failed: {}", e); Status::unauthenticated("message not authenticated") })?; diff --git a/services/identity/src/tunnelbroker.rs b/services/identity/src/tunnelbroker.rs --- a/services/identity/src/tunnelbroker.rs +++ b/services/identity/src/tunnelbroker.rs @@ -16,7 +16,10 @@ shared_tb_client(&CONFIG.tunnelbroker_endpoint) .await .map_err(|e| { - error!("Unable able to connect to tunnelbroker: {:?}", e); + error!( + "Tunnelbroker Error: Unable able to connect to tunnelbroker: {:?}", + e + ); Error::Status(Status::invalid_argument(format!("{}", e))) }) } diff --git a/services/identity/src/websockets/auth.rs b/services/identity/src/websockets/auth.rs --- a/services/identity/src/websockets/auth.rs +++ b/services/identity/src/websockets/auth.rs @@ -28,7 +28,7 @@ let mut grpc_client = match grpc_client { Ok(grpc_client) => grpc_client, Err(e) => { - error!("Failed to get unauthenticated client: {}", e); + error!("Search Error: Failed to get unauthenticated client: {}", e); return Err(WebsocketError::AuthError); } }; @@ -43,7 +43,7 @@ let response = match grpc_client.verify_user_access_token(request).await { Ok(response) => response, Err(_) => { - error!("Failed to verify user access token"); + error!("Search Error: Failed to verify user access token"); return Err(WebsocketError::AuthError); } }; @@ -58,7 +58,7 @@ let auth_message: IdentitySearchAuthMessage = match auth_message { Ok(auth_message) => auth_message, Err(_) => { - error!("Failed to parse auth message"); + error!("Search Error: Failed to parse auth message"); return Err(WebsocketError::InvalidMessage); } }; diff --git a/services/identity/src/websockets/errors.rs b/services/identity/src/websockets/errors.rs --- a/services/identity/src/websockets/errors.rs +++ b/services/identity/src/websockets/errors.rs @@ -13,14 +13,14 @@ impl From for WebsocketError { fn from(err: serde_json::Error) -> Self { - tracing::error!("Error serializing: {}", err); + tracing::error!("Search Error: Error serializing: {}", err); WebsocketError::SerializationError } } impl From for WebsocketError { fn from(err: reqwest::Error) -> Self { - tracing::error!("Error with search request: {}", err); + tracing::error!("Search Error: Error with search request: {}", err); WebsocketError::SearchError } } diff --git a/services/identity/src/websockets/mod.rs b/services/identity/src/websockets/mod.rs --- a/services/identity/src/websockets/mod.rs +++ b/services/identity/src/websockets/mod.rs @@ -113,7 +113,10 @@ tokio::spawn(async move { if let Err(err) = connection.await { - error!("Error serving HTTP/WebSocket connection: {:?}", err); + error!( + "Search Error: Error serving HTTP/WebSocket connection: {:?}", + err + ); } }); } @@ -139,7 +142,7 @@ #[tracing::instrument(skip_all)] async fn close_connection(outgoing: WebsocketSink) { if let Err(e) = outgoing.lock().await.close().await { - error!("Error closing connection: {}", e); + error!("Search Error: Error closing connection: {}", e); } } @@ -229,7 +232,7 @@ let ws_stream = match hyper_ws.await { Ok(stream) => stream, Err(e) => { - error!("WebSocket handshake error: {}", e); + error!("Search Error: WebSocket handshake error: {}", e); return; } }; @@ -267,13 +270,13 @@ } } _ => { - error!("Invalid authentication message from {}", addr); + error!("Search Error: Invalid authentication message from {}", addr); close_connection(outgoing).await; return; } } } else { - error!("No authentication message from {}", addr); + error!("Search Error: No authentication message from {}", addr); close_connection(outgoing).await; return; } @@ -309,19 +312,19 @@ ping_timeout = Box::pin(tokio::time::sleep(SOCKET_HEARTBEAT_TIMEOUT)); if let Err(e) = handle_websocket_frame(text, outgoing.clone()).await { - error!("Error handling WebSocket frame: {}", e); + error!("Search Error: Error handling WebSocket frame: {}", e); continue; }; } _ => { - error!("Client sent invalid message type"); + error!("Search Error: Client sent invalid message type"); break; } } } _ = &mut ping_timeout => { if !got_heartbeat_response { - error!("Connection to {} died.", addr); + error!("Search Error: Connection to {} died.", addr); break; } let serialized = serde_json::to_string(&Heartbeat {}).unwrap(); diff --git a/services/identity/src/websockets/send.rs b/services/identity/src/websockets/send.rs --- a/services/identity/src/websockets/send.rs +++ b/services/identity/src/websockets/send.rs @@ -14,6 +14,6 @@ #[tracing::instrument(skip_all)] pub async fn send_message(message: Message, outgoing: WebsocketSink) { if let Err(e) = outgoing.lock().await.send(message).await { - error!("Failed to send message to device: {}", e); + error!("Search Error: Failed to send message to device: {}", e); } }