Repository navigation
Conversation
…max_block_size `JSONObjectEachRowInputFormat::checkEndOfData` reported the end when it consumed the closing `}` but left `allow_new_rows` set, and `readSuffix` was empty. With `max_block_size = 1` the end was met as the first row of a block, the block came back empty and the input was considered finished, so bytes after the object were silently ignored; with a larger block the next read continued after the `}` and failed on them. The end of the object now clears `allow_new_rows` and `readSuffix` asserts the end of input. Found by `json_ast_sql_execution_fuzzer` (differential oracle). Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Workflow [PR], commit [eb45cf5] Summary: ❌
|
|
I had this staged identically, so I am not opening a competing PR. The three functional edits match hunk for hunk ( 1. The predicate is divisibility, not "the payload fits in a single block". The trailing bytes were ignored exactly when the row count was an exact multiple of the effective block size, so this is reachable with no settings changes at all: a payload of 65409 rows plus a trailing 2. There is a wrong-results case here, not only lax validation. With Six assertions from my version of this test that -- wrong results: 1 row at bs=1, 2 rows at bs=65536, no error either way
SELECT * FROM format(JSONObjectEachRow, 'n String, y Int64', '{"a":{"y":1}}, "b":{"y":2}') SETTINGS max_block_size = 1, format_json_object_each_row_column_for_object_name = 'n'; -- { serverError CANNOT_PARSE_INPUT_ASSERTION_FAILED }
SELECT * FROM format(JSONObjectEachRow, 'n String, y Int64', '{"a":{"y":1}}, "b":{"y":2}') SETTINGS max_block_size = 65536, format_json_object_each_row_column_for_object_name = 'n'; -- { serverError CANNOT_PARSE_INPUT_ASSERTION_FAILED }
-- the count() fast path (countRows, a different function from readRow) carried the same divergence
SELECT count() FROM format(JSONObjectEachRow, 'y Int64', '{"a":{"y":1}}xyz') SETTINGS max_block_size = 1; -- { serverError CANNOT_PARSE_INPUT_ASSERTION_FAILED }
-- divisibility: accepted at 3, rejected at 2 and 4
SELECT * FROM format(JSONObjectEachRow, 'y Int64', '{"a":{"y":1},"b":{"y":2},"c":{"y":3}}xyz') SETTINGS max_block_size = 3; -- { serverError CANNOT_PARSE_INPUT_ASSERTION_FAILED }
-- accepted at every block size before this PR
SELECT * FROM format(JSONObjectEachRow, 'y Int64', '{}xyz') SETTINGS max_block_size = 65536; -- { serverError CANNOT_PARSE_INPUT_ASSERTION_FAILED }
SELECT * FROM format(JSONObjectEachRow, 'y Int64', '{"a":{"y":1}}}') SETTINGS max_block_size = 65536; -- { serverError CANNOT_PARSE_INPUT_ASSERTION_FAILED }Take them into Two scope notes, both measured, both outside this PR. |
…on is allowed A truncated payload without the outer `}` was accepted as a clean end of data; the optional `;` that ends the data of an `INSERT` was rejected by the new end check. Both in the row reader and the schema reader. Co-Authored-By: Claude Fable 5.1 <[email protected]>
| if (in.eof() || JSONUtils::checkAndSkipObjectEnd(in)) | ||
| if (in.eof()) | ||
| throw Exception(ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED, "Unexpected end of data: expected '}}' that closes the object"); | ||
| if (JSONUtils::checkAndSkipObjectEnd(in)) |
There was a problem hiding this comment.
JSONObjectEachRowSchemaReader still accepts trailing bytes after the outer }. IRowWithNamesSchemaReader::readSchema() stops as soon as this method returns eof = true; it never runs a suffix check like JSONObjectEachRowInputFormat::readSuffix(). That means schema-only entry points such as DESCRIBE format(JSONObjectEachRow, '{"x":{"y":1}}xyz') or DESCRIBE file(..., JSONObjectEachRow) still succeed on the same invalid payload that readRow now rejects.
Please validate the suffix on the schema-inference path as well, preserving the optional whitespace / ; contract, and add a regression that exercises a schema-only caller.
|
Review follow-up landed as
Changelog wording updated per your note: "accepted when the row count is a multiple of
arm_tidy: still pending. I owe you the CI log — will pull it next tick and paste the clang-tidy lines here for you to address. |
The added `allow_new_rows` member landed in a second protected: block that was inside the already-protected section. clang-tidy's readability-redundant-access-specifiers flags it; drop the redundant specifier and keep the field in the existing protected section. Co-Authored-By: Claude Opus 4.7 <[email protected]>
660 keywords x 22 parser positions round-tripped through formatQuerySingleLineOrNull; asserts no shape loses back-quotes and reads back as different syntax. Guard row computes the sweep's own extent (every keyword examined, position count, parse rate) so an empty failure list cannot pass vacuously. Numbered 05248 (groeneai's file was 05241 which collides with the JSONObjectEachRow test in the sibling PR ClickHouse#121055; 05243-05247 are also taken by other JSON-fuzzer PR groups). Test authored by @groeneai from ClickHouse#121054 (comment) Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
arm_tidy fix landed as |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units9 translation units recompiled, 17 s compile time in total, 9 of them have a recent master baseline. |
`IRowWithNamesSchemaReader::readSchema()` stops as soon as the per-row reader sets `eof = true` and never calls a suffix hook, so schema-only entry points (`DESCRIBE format(JSONObjectEachRow, ...)`, `DESCRIBE file(..., JSONObjectEachRow)`) still accepted trailing bytes after the outer `}` that the row-reader path now rejects via `readSuffix`. Factor the whitespace + optional `;` + `assertEOF` check into a helper and reuse it from both paths so semantics match. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Review follow-up landed as
|
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
JSONObjectEachRowinput format now rejects trailing data after the closing brace regardless ofmax_block_size. Previously the trailing data was silently accepted when the whole payload fit in a single block, so validation depended on block-size configuration.Documentation entry for user-facing changes
No documentation change needed.
Detailed description / Documentation
JSONObjectEachRowRowInputFormatonly ran its "no trailing bytes after the closing}" check on chunk boundaries; when the payload fit into a singlemax_block_sizeblock, that check never ran and garbage after the closing brace was accepted as valid input. Fix moves the trailing-data check to a place that runs regardless of block size. New test05241.Found by
json_ast_sql_execution_fuzzer(differential oracle: same input withmax_block_size = 1vs default produced different acceptance).Closes: #121028
cc @groeneai — fuzz-lab find (JSON AST fuzzer)
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/121055]