Skip to content

Commit

Permalink
feat(server): improve logging for deserializing invalid server command
Browse files Browse the repository at this point in the history
  • Loading branch information
mmodzelewski committed Feb 17, 2025
1 parent 7a9bbde commit 19cab54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion server/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ use iggy::{
};
use std::fmt::{Display, Formatter};
use strum::EnumString;
use tracing::error;

#[derive(Debug, PartialEq, EnumString)]
pub enum ServerCommand {
Expand Down Expand Up @@ -263,7 +264,10 @@ impl BytesSerializable for ServerCommand {
GET_SNAPSHOT_FILE_CODE => Ok(ServerCommand::GetSnapshotFile(GetSnapshot::from_bytes(
payload,
)?)),
_ => Err(IggyError::InvalidCommand),
_ => {
error!("Invalid server command: {code}");
Err(IggyError::InvalidCommand)
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion server/src/tcp/connection_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pub(crate) async fn handle_connection(
sender.read(&mut command_buffer).await?;
let command = ServerCommand::from_bytes(command_buffer.freeze());
if command.is_err() {
error!("Received an invalid TCP command.");
sender
.send_error_response(IggyError::InvalidCommand)
.await?;
Expand Down

0 comments on commit 19cab54

Please # to comment.