Skip to content

Commit 6eb0646

Browse files
committed
Added row id validation
1 parent 50f04ff commit 6eb0646

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ydb/core/fq/libs/row_dispatcher/json_parser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,13 @@ class TJsonParser::TImpl {
328328
with_lock (Alloc) {
329329
ClearColumns(Buffer.NumberValues);
330330

331+
const ui64 firstOffset = Buffer.Offsets.front();
331332
size_t rowId = 0;
332333
simdjson::ondemand::document_stream documents = Parser.iterate_many(values, size, simdjson::ondemand::DEFAULT_BATCH_SIZE);
333334
for (auto document : documents) {
335+
if (Y_UNLIKELY(rowId >= Buffer.NumberValues)) {
336+
throw yexception() << "Failed to parse json messages, expected " << Buffer.NumberValues << " json rows from offset " << firstOffset << " but got " << rowId;
337+
}
334338
for (auto item : document.get_object()) {
335339
const auto it = ColumnsIndex.find(item.escaped_key().value());
336340
if (it == ColumnsIndex.end()) {
@@ -348,7 +352,6 @@ class TJsonParser::TImpl {
348352
rowId++;
349353
}
350354

351-
const ui64 firstOffset = Buffer.Offsets.front();
352355
if (rowId != Buffer.NumberValues) {
353356
throw yexception() << "Failed to parse json messages, expected " << Buffer.NumberValues << " json rows from offset " << firstOffset << " but got " << rowId;
354357
}

0 commit comments

Comments
 (0)