Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/moderationservice/kafka/kafkaclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,16 @@ void KafkaConsumer::ProcessMessage(RdKafka::Message* message) {

std::string key_str(key_ptr, message->key_len());

// Validate that key_str contains only digits (and optional leading +/-)
if (key_str.empty() || (!std::isdigit(key_str[0]) && key_str[0] != '-' && key_str[0] != '+')) {
std::cerr << "Invalid message key format (not numeric): '" << key_str << "'\n";
return;
}

try {
request_id = std::stoll(key_str);
} catch (const std::exception& e) {
std::cerr << "Failed to parse message key to request ID: " << e.what() << "\n";
std::cerr << "Failed to parse message key '" << key_str << "' to request ID: " << e.what() << "\n";
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tools/common.just
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ build-windows: fetch-proto

kafka-container-up:
docker-compose up -d
MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-result --replication-factor 1 --partitions 3
MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-request --replication-factor 1 --partitions 3
MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-result --replication-factor 1 --partitions 3 || true
MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-request --replication-factor 1 --partitions 3 || true

kafka-container-down:
MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic moderation-request
Expand Down
Loading