Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logs for unsupported commands and invalid requests #15

Merged
merged 1 commit into from
Mar 8, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1133,12 +1133,14 @@ SplitRequestPtr InstanceImpl::makeRequest(Common::Redis::RespValuePtr&& request,
SplitCallbacks& callbacks, Event::Dispatcher& dispatcher,
const StreamInfo::StreamInfo& stream_info) {
if ((request->type() != Common::Redis::RespType::Array) || request->asArray().empty()) {
ENVOY_LOG(debug,"invalid request - not an array or empty");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "invalid request - not an array or array is empty" ?

onInvalidRequest(callbacks);
return nullptr;
}

for (const Common::Redis::RespValue& value : request->asArray()) {
if (value.type() != Common::Redis::RespType::BulkString) {
ENVOY_LOG(debug,"invalid request - not an array of bulk strings");
onInvalidRequest(callbacks);
return nullptr;
}
Expand All @@ -1156,6 +1158,7 @@ SplitRequestPtr InstanceImpl::makeRequest(Common::Redis::RespValuePtr&& request,

if (command_name == Common::Redis::SupportedCommands::auth()) {
if (request->asArray().size() < 2) {
ENVOY_LOG(debug,"invalid request - not enough arguments for auth command");
onInvalidRequest(callbacks);
return nullptr;
}
Expand Down Expand Up @@ -1215,6 +1218,7 @@ SplitRequestPtr InstanceImpl::makeRequest(Common::Redis::RespValuePtr&& request,
if (request->asArray().size() < 2 &&(Common::Redis::SupportedCommands::transactionCommands().count(command_name) == 0)
&& (Common::Redis::SupportedCommands::subcrStateallowedCommands().count(command_name) == 0)){
// Commands other than PING, TIME and transaction commands all have at least two arguments.
ENVOY_LOG(debug,"invalid request - not enough arguments for command: '{}'", command_name);
onInvalidRequest(callbacks);
return nullptr;
}
Expand All @@ -1223,6 +1227,7 @@ SplitRequestPtr InstanceImpl::makeRequest(Common::Redis::RespValuePtr&& request,
auto handler = handler_lookup_table_.find(command_name.c_str());
if (handler == nullptr && !callbacks.transaction().isSubscribedMode()) {
stats_.unsupported_command_.inc();
ENVOY_LOG(debug, "unsupported command '{}'", request->asArray()[0].asString());
callbacks.onResponse(Common::Redis::Utility::makeError(
fmt::format("unsupported command '{}'", request->asArray()[0].asString())));
return nullptr;
Expand Down