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 794a6d5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "server"
version = "0.4.205"
version = "0.4.206"
edition = "2021"
build = "src/build.rs"
license = "Apache-2.0"
Expand Down
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 794a6d5

Please # to comment.