diff options
author | va-kuznecov <va-kuznecov@ydb.tech> | 2023-08-29 16:31:23 +0300 |
---|---|---|
committer | va-kuznecov <va-kuznecov@ydb.tech> | 2023-08-29 21:36:42 +0300 |
commit | 9044559cb8d2e4e1c992c87631cb4ee9d2689643 (patch) | |
tree | 026559441855be5e475cdf6a7f216b3aead3a364 | |
parent | ea6d868f6e215711597d9ca9d3e6b29a982c0e86 (diff) | |
download | ydb-9044559cb8d2e4e1c992c87631cb4ee9d2689643.tar.gz |
Reply with BAD_REQUEST if there is no keys in ReadRows request KIKIMR-19178
-rw-r--r-- | ydb/core/grpc_services/rpc_read_rows.cpp | 4 | ||||
-rw-r--r-- | ydb/core/kqp/ut/opt/kqp_kv_ut.cpp | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/ydb/core/grpc_services/rpc_read_rows.cpp b/ydb/core/grpc_services/rpc_read_rows.cpp index 385e6af277..ffcada8ff6 100644 --- a/ydb/core/grpc_services/rpc_read_rows.cpp +++ b/ydb/core/grpc_services/rpc_read_rows.cpp @@ -400,6 +400,10 @@ public: if (!CheckAccess(resolveNamesResult.Get(), errorMessage)) { return ReplyWithError(Ydb::StatusIds::UNAUTHORIZED, errorMessage); } + const auto& keys = GetProto()->Getkeys().Getvalue().Getitems(); + if (keys.empty()) { + return ReplyWithError(Ydb::StatusIds::BAD_REQUEST, "no keys are found in request's proto"); + } if (!BuildSchema(resolveNamesResult.Get(), errorMessage)) { return ReplyWithError(Ydb::StatusIds::SCHEME_ERROR, errorMessage); diff --git a/ydb/core/kqp/ut/opt/kqp_kv_ut.cpp b/ydb/core/kqp/ut/opt/kqp_kv_ut.cpp index 161efb88fa..4f39ba072f 100644 --- a/ydb/core/kqp/ut/opt/kqp_kv_ut.cpp +++ b/ydb/core/kqp/ut/opt/kqp_kv_ut.cpp @@ -269,6 +269,14 @@ Y_UNIT_TEST_SUITE(KqpKv) { [14u;4u;"abcde"] ])", res); } + { + NYdb::TValueBuilder keys; + keys.BeginList(); + keys.EndList(); + + auto selectResult = db.ReadRows("/Root/TestTable", keys.Build()).GetValueSync(); + UNIT_ASSERT_EQUAL(selectResult.GetStatus(), EStatus::BAD_REQUEST); + } } Y_UNIT_TEST(ReadRows_SpecificReturnValue) { |