Repository navigation
fix(expression): report a character outside the grammar without closing the connection - #567
Conversation
…e does, without a panic The tokenizer behind condition and filter expressions read the offending byte as a char and sliced the input five bytes either side of it. When that range ended inside a multi-byte character (`#v = ééé`, `#v = 日本語`) the slice panicked, the request task ended and the connection closed; the server's key condition parse ahead of authorization calls the same tokenizer, so a Query key condition did the same for every principal. Other multi-byte input answered a token made of the first byte read as Latin-1. The tokenizer behind update, projection and the engine's key condition parse did not panic and answered the character with one byte after it as the window. The error now names the character as sent and shows the service's window: the source text from the start of the previous token to the end of the next one, with each character outside the grammar counted as one token (measured 2026-10-25, each request twice: `#v = ééé` answers `token: "é", near: "= éé"`, `abéc = :v` answers `near: "abéc"`, `#v = $x` answers `near: "= $x"`). Both tokenizer entry points share the rule.
Pure move, using the #[path] pattern evaluator_tests.rs uses; tokenizer.rs had grown past 600 lines with the previous commit.
…rammar Every row is a request measured against the service on 2026-10-25, each sent twice: Scan filters with multi-byte and ASCII characters outside the grammar in each position, and one or two rows each for PutItem conditions, Query key conditions, UpdateItem update expressions and GetItem projections.
…drop U+0000, as the service does When no token comes before the character, the service starts the window at the start of the expression and keeps the leading whitespace (` é = :v` answers `near: " é ="`), and it removes U+0000 from the token and the window (`#v = \0x` answers `token: "", near: "= x"`). Measured 2026-10-25 at 16:34, 16:38 and 16:43 UTC, each request twice. The unit table gains those rows and the rows that pin the next-token rules for two-character operators, name runs and digit runs.
…ken rules and the Query paths Rows measured on 2026-10-25 at 16:34, 16:38, 16:43 and 16:54 UTC, each request twice: a character with no token before it, U+0000, two-character operators, name runs and digit runs after the character, and the panic shape on a Query key condition, a Query filter and an UpdateItem condition. The prefix the service adds on write paths is stripped only on those paths.
crates/core/src/expression/tokenizer.rs: main fixed the panic in tokenize_with_limit by moving both ends of the five-byte window out to character boundaries and reporting the whole character as the token. This branch answers the window the service answers, measured on 2026-10-25: from the start of the previous token to the end of the next one, from the start of the expression when no token comes before the character, with U+0000 removed. The result keeps this branch's unknown_character and next_token_end, which slice on character boundaries and so cover the panic main fixed. main's five-byte window code is superseded. The tests stay in tokenizer_tests.rs, where this branch moved them. main's three new tests move from tokenizer.rs into tokenizer_tests.rs. tokenize_multibyte_utf8_near_an_invalid_byte_does_not_panic stays as main wrote it; its one window assertion, "$ 日" for the input "$ 日", matches the measured rule. tokenize_reports_the_whole_invalid_character keeps its token assertion, and its window for "a = é" changes from "a = é" to "= é", the window the measured row for "#v = é" gives. tokenize_ascii_error_context_is_five_bytes_either_side is dropped: it asserted the window "s(a) $ b" for "attribute_exists(a) $ b", five bytes either side of the character, and the measured rule answers ") $ b" for that input.
demohan
left a comment
There was a problem hiding this comment.
The token and window now match the service on the request kinds I measured, on all four backends, and I found no regression against main. Three changes and five small ones remain, listed inline. Measured on 2026-11-12 in us-east-1, each request twice.
Separate from this PR, I will file these as issues: a bare name starting with _ is accepted and stored, where the service refuses it (SET _abc = :v answers token: "_", near: "SET _abc"); and Query and TransactWriteItems report faults across parameters in a different order from the service.
| b'>' if bytes.get(i + 1) == Some(&b'=') => i + 2, | ||
| b'(' | b')' | b'[' | b']' | b',' | b'.' | b'+' | b'-' | b'=' | b'<' | b'>' => i + 1, | ||
| b'#' | b':' => run(i + 1, is_ident_char), | ||
| c if is_ident_start(c) => run(i, is_ident_char), |
There was a problem hiding this comment.
The service ends the window after a leading _. Scan #v = é _abc answers token: "é", near: "= é _", and UpdateItem SET #v = é _abc answers near: "= é _". This arm reads _abc as one name and answers near: "= é _abc" (__x gives "= é __x", where the service gives "= é _"). Starting the name run at an ASCII letter here, with _ taking the one-character arm, matches the service. a_b already matches.
There was a problem hiding this comment.
next_token_end starts a name run with is_ident_start, so the fix goes there. The fix for #1018, #1131, makes is_ident_start accept only a letter, so _abc and __x take the one-character arm. It builds on this branch and adds rows for #v = é _abc and #v = é __x. DynamoDB answers near: "= é _" for both (measured 18 Nov 2026). The same change refuses _x as a name, which #1018 tracks.
| (token, input[start..end].replace('\0', "")) | ||
| } | ||
|
|
||
| /// The byte offset where the next token after `from` ends, skipping the |
There was a problem hiding this comment.
This does not follow tokenize_with_limit for a bare # or :: it counts each as a one-byte token, which the tokenizer refuses. That matches the service (#v = é # x answers near: "= é #", and #v = é : answers near: "= é :"), so the doc should say so.
There was a problem hiding this comment.
Done in 251a89c. The doc of next_token_end now says that a bare # or : counts as a one-byte token, as DynamoDB counts it.
| fn next_token_end(input: &str, from: usize) -> Option<usize> { | ||
| let bytes = input.as_bytes(); | ||
| let mut i = from; | ||
| while i < bytes.len() && matches!(bytes[i], b' ' | b'\t' | b'\n' | b'\r') { |
There was a problem hiding this comment.
No test pins which whitespace this skips. Limiting the skip to spaces passes the unit table and the wire file. The service answers near: "= é\tabc" for #v = é\tabc, near: "= é\n:v" for #v = é\n:v and near: "= é\r:v" for #v = é\r:v, and this code gives the same. Rows for tab, LF and CR would pin it.
There was a problem hiding this comment.
Added in 251a89c: rows for a tab, a line feed and a carriage return before the next token. DynamoDB's near texts are = é\tabc, = é\n:v and = é\r:v (measured 18 Nov 2026, each request twice).
|
|
||
| #[test] | ||
| fn tokenize_multibyte_utf8_near_an_invalid_byte_does_not_panic() { | ||
| // Each input has an invalid byte whose five-byte context window ends |
There was a problem hiding this comment.
This comment and the one at line 195 describe the five-byte window, which the tokenizer no longer builds.
There was a problem hiding this comment.
Rewritten in 251a89c. Both comments now describe the window from the start of the previous token to the end of the next one.
| }; | ||
| assert_eq!(msg, expected, "{expr}"); | ||
| let Err(DynamoDbError::ValidationException(msg)) = | ||
| tokenize_for(expr, 4096, super::super::ExpressionKind::Filter) |
There was a problem hiding this comment.
tokenize_for never receives the Filter kind in production. This is also the only unit check of the tokenize_for window: with it removed, mutations to that loop pass the unit suite. The Update or Projection kind would cover the path that runs.
There was a problem hiding this comment.
Changed in 251a89c. The table check of tokenize_for uses the Update kind, which production passes.
| // for `#v = é` in `UNKNOWN_CHARACTER_ROWS`. | ||
| let err = tokenize("a = \u{e9}").unwrap_err(); | ||
| assert!( | ||
| matches!(err, DynamoDbError::ValidationException(ref msg) |
There was a problem hiding this comment.
assert_eq! on the full message would pin the window. contains also passes when text is added around it.
There was a problem hiding this comment.
Changed in 251a89c. The test compares the whole message with assert_eq!.
| return err["Message"] | ||
|
|
||
|
|
||
| def _after_prefix(msg: str) -> str: |
There was a problem hiding this comment.
This passes whether or not the target sends 1 validation error detected: . The service sent it on all 105 PutItem, UpdateItem and DeleteItem validation errors I measured, and ExtendDB sends it on none. Asserting the full text, with these rows marked as an expected failure until the prefix is added, keeps the difference visible.
There was a problem hiding this comment.
There was a problem hiding this comment.
Changed again in c17f737, after the later comment on this file. The 9 rows compare the token and the window on every target. On ExtendDB a row is an expected failure only when the message is the service's text without the count. With let start = at; in a SQLite build, the 9 rows fail.
| ("#v[\u00e912] = :v", "\u00e9", "[\u00e912"), | ||
| ], | ||
| ) | ||
| def test_scan_filter(dynamodb_client, table, expr, token, near): |
There was a problem hiding this comment.
No rows cover DeleteItem conditions, the four TransactWriteItems kinds, projections on Query, Scan, BatchGetItem and TransactGetItems, or a GSI key condition. The change answers all of them as the service does. For example, TransactWriteItems ConditionCheck #v = é answers Invalid ConditionExpression: Syntax error; token: "é", near: "= é" with no prefix, and GSI Query g = ééé answers near: "= éé". Rows for these, and for the _ case above, would pin them.
There was a problem hiding this comment.
Added in 251a89c as one table, OPERATION_ROWS, with one parametrized test. It has a DeleteItem condition and the four TransactWriteItems kinds. It also has a projection on Query, Scan, BatchGetItem and TransactGetItems, and a key condition on a global secondary index. Each expected text is DynamoDB's answer from 18 Nov 2026, and each request went out twice. The rows for _ go with the fix for #1018, because they need its change.
New rows in the tokenizer table cover a tab, a line feed and a carriage return before the next token. The doc of next_token_end says that a bare # or : counts as a one-byte token, as DynamoDB counts it. One window check now compares the whole message with assert_eq. The table check of tokenize_for uses the Update kind, which production passes. Two test comments now describe the window the tokenizer builds. The wire tests compare the whole PutItem, UpdateItem and DeleteItem message, which starts with the count "1 validation error detected: ". Those rows are an expected failure on ExtendDB, which leaves the count out. New wire rows cover a DeleteItem condition and the four TransactWriteItems kinds. More rows cover a projection on Query, Scan, BatchGetItem and TransactGetItems, and a key condition on a global secondary index. They share one data table and one parametrized test. Each new row expects the text DynamoDB returned on 2026-11-18 in us-east-1. Each request went out twice and got the same answer both times.
demohan
left a comment
There was a problem hiding this comment.
The inline items from the earlier review are resolved at 251a89c, except the window after a leading _, which #1131 carries on this branch. Each request was sent twice to the service and to SQLite and PostgreSQL builds of this head.
- A bare
#or:answersnear: "= é #"andnear: "= é :", as the service does. Tab, LF, CR, vertical tab and form feed before the next token match the service. - The 10 new operation rows match the service's text. The wire file passes 60 of 60 against the service, twice.
- 2,000,000 random inputs through
tokenize_forproduced no panic, and everynear:window is a substring of its input. - Each new unit row fails with its window or whitespace rule broken. CI is green on 64 of 64 checks.
I will approve once #1131 is merged into this branch and the test note below is done. Scan #v = é _abc answers near: "= é _" on the service and near: "= é _abc" here. The rows in #1131 expect the service's window.
PR body
Optional. The body gives 44 unit rows, 50 wire tests and 449 lines, and its gate figures come from 807937e. At this head there are 47 rows, 60 wire tests and 450 lines.
| # ExtendDB sends the message of a PutItem, UpdateItem or DeleteItem | ||
| # validation error without the count before it. Not strict, so a server that | ||
| # sends the count passes these rows. | ||
| MISSING_COUNT = pytest.mark.xfail( |
There was a problem hiding this comment.
MISSING_COUNT marks the whole assertion as an expected failure, so on ExtendDB the 9 PutItem, UpdateItem and DeleteItem rows no longer check the token or the window. With the window start broken in the server, ExtendDB answered near: "SET #v = éé" and the 9 rows still reported XFAIL. Comparing the text after 1 validation error detected: every time, and marking only the missing prefix as expected to fail, keeps the window checked on every backend.
There was a problem hiding this comment.
Done in c17f737. _assert_message ends a row as an expected failure on ExtendDB only when the message is the service's text without 1 validation error detected: . Any other message must equal the service's text, so the 9 rows compare the token and the window on every target.
I checked it on synthetic messages. A wrong window now fails on ExtendDB, with the count and without it. A message with no count still fails on the service. The file collects 60 tests, as before.
There was a problem hiding this comment.
I ran your check against a server as well. With let start = at; in a SQLite build, the 9 rows now fail. Against the same build, the file of 251a89c reports them as XFAIL.
On the build without that change the 9 rows are expected failures. With --runxfail, each one differs from the service's text only by the count.
The file now collects 63 tests. 54dfb6a and ade81dc add three Scan filter rows.
On PutItem, UpdateItem and DeleteItem the service starts the message with the count '1 validation error detected: ', which ExtendDB leaves out of this error. The nine rows of those operations had an expected failure mark for ExtendDB. The mark covered the whole assertion, so on ExtendDB those rows did not check the token or the window. _assert_message ends the test as an expected failure on ExtendDB only when the message is the service's text without the count. Any other message must equal the service's text, so the token and the window are compared on every target.
…tion passes The doc of unknown_character puts the five expression parameter names in backticks, which clears five clippy::doc_markdown warnings. The module doc of the tokenizer uses a colon where it had a dash. tokenize_for_multibyte_utf8_does_not_panic calls tokenize_for with the KeyCondition, Projection and Update kinds. Production passes only these three kinds to tokenize_for. The test used the Condition and Filter kinds before.
…token follows When only whitespace follows a character outside the grammar, DynamoDB keeps that whitespace in the window. Scan with the filter "#v = é " answers near: "= é ", and " é " answers near: " é ". Until now the window ended at the character, so ExtendDB answered "= é" and " é". unknown_character now ends the window at the end of the expression when next_token_end finds no token. Two rows in the tokenizer table and two Scan filter rows in the wire tests cover this case. Each expects the text DynamoDB returned on 2026-11-24 in us-east-1. Each request went out twice and got the same answer both times.
…e grammar DynamoDB refuses a filter that starts with U+FEFF. Scan with the filter "\ufeff#v = :v" answers token: "\ufeff", near: "\ufeff#v", by the same rule as every other character outside the grammar. ExtendDB gives the same text. A row in the tokenizer table and a Scan filter row in the wire tests pin it. Each row expects the text DynamoDB returned on 2026-11-24 in us-east-1. Each request went out twice and got the same answer both times.
demohan
left a comment
There was a problem hiding this comment.
The items from the earlier review are resolved at ade81dc, apart from the window after a leading _, which #1131 carries. Each request was sent twice to the service in us-east-1 and to SQLite and PostgreSQL builds of this head and of 251a89c.
- The window now runs to the end of the expression when only whitespace follows the character, which fixes 19 shapes across all five expression kinds (
#v = é \t\n\r,contains(#v, é, a Querysk = é \t, 1000 trailing spaces). 2,000,000 random expressions through both tokenizers, twice, give no panic, every window is a substring of the input, and the window reaches the end whenever only whitespace follows; with the earlier line put back the same run reports 95,618 violations. - The rows now catch a broken window: breaking the update window fails 4 of the 5
test_update_expressionrows and breaking the condition window fails the PutItem, UpdateItem and DeleteItem rows, where at 251a89c they stayed expected failures. The 9 rows that lack the count end as expected failures that equal the service's message without1 validation error detected:. All 63 rows pass against the service twice. - No request that matched the service at 251a89c differs here (190 requests), PostgreSQL answers as SQLite, the body's counts match, fmt, clippy and the 1.91.1 check of
extenddb-coreare clean, and CI is green on 64 of 64 checks. #v = é _abc,#v = é __xandSET #v = é _abcstill answernear: "= é _abc"and"= é __x", where the service answersnear: "= é _";is_ident_startaccepts_until #1131 lands, as the body says. #1131 and this branch conflict intokenizer_tests.rs.
Main is at 80490c6, eight commits after the last merge (#596, #1173, #398, #428, #544, #567, #584 and #588). One file conflicted: crates/engine/src/query.rs. #544 moves the Limit check and the parameter mix check of Query into validate_query_request_body, which reads the raw body before deserialization. This branch moves the same two checks to the start of the handler, after deserialization. The merge keeps the checks of #544 and drops the copies of this branch, which no request can reach. It keeps has_cond_op for the ConditionalOperator check. The conflict hunks in handle_query: - At the old Limit check, both sides remove the check. The merge keeps the comment of #544. - Next, this branch keeps the variables of the mix check, and main keeps the index key schema. The merge keeps the key schema where this branch has it. It drops the mix check variables, which nothing reads now, and keeps the comment of #544 and has_cond_op. - Before the ExclusiveStartKey check, this branch removes the filter operand checks, because its semantic pass runs them at parse time. #544 adds validate_key_condition_types there. The merge keeps the type check and drops the filter checks. #544 refuses a begins_with value that is not an S or a B ahead of an unused value (rows q5 and p4 of tests/test_query_key_value_types.py, measured 2026-11-06). This branch checks unused values before the table lookup, so the merged code gave the unused value message for those two rows. The merge calls refuse_begins_with_on_number after the key condition parse and removes the later call. The values of legacy KeyConditions pass validate_legacy_conditions before that point. Git merged four other files that both sides change, with no overlap: crates/core/src/expression/key_condition.rs, crates/engine/src/lib.rs, crates/storage-cassandra/tests/common/mod.rs and docs/differences-from-dynamodb.md.
Main is at 80490c6, six commits after the last merge (#398, #428, #544, #567, #584 and #588). Two files conflicted. crates/engine/src/lib.rs: this branch adds query_key_size_tests and #544 adds query_key_values to the module list. The merge keeps both in name order. crates/engine/src/query.rs, two hunks in handle_query: - This branch moves validate_query_select_index_support after the start key checks, and #544 replaces the Limit check with a comment. The merge removes the early Select check and keeps the comment of #544. - Before the ExclusiveStartKey check, this branch adds validate_query_key_sizes and #544 adds validate_key_condition_types. The merge runs the type check first, because the key size comment records a wrong-typed key value ahead of the size (measured 2026-10-23). On a single-attribute key schema #544 checks the type there and not in resolve_key_schema_with, so the key size comment now says "checked above".
Main is at 80490c6, six commits after the last merge (#398, #428, #544, #567, #584 and #588). One file conflicted: crates/engine/src/query.rs. This branch moves the table lookup, the index lookup and the index key schema below the request-stage checks. #544 moves the Limit check and the parameter mix check into validate_query_request_body, which reads the raw body before deserialization. Three conflict hunks in handle_query follow from this: - After deserialization, this branch keeps the Limit check and main keeps the table lookup. The merge keeps the lookup where this branch has it and puts the comment of #544 in place of the Limit check. - Next, this branch keeps the variables of the mix check and main keeps the index key schema. The merge keeps the key schema where this branch has it. It drops the mix check variables, which nothing reads now, and keeps the comment of #544 and has_cond_op. - Before the ExclusiveStartKey check, this branch removes the filter operand checks, because its semantic pass runs them at parse time. #544 adds validate_key_condition_types there. The merge keeps the type check and drops the filter checks. #544 refuses a begins_with value that is not an S or a B ahead of an unused value (rows q5 and p4 of tests/test_query_key_value_types.py, measured 2026-11-06). This branch checks unused values before the table lookup, so the merged code gave the unused value message for those two rows. The merge calls refuse_begins_with_on_number after the key condition parse and removes the later call. The values of legacy KeyConditions pass validate_key_conditions before that point. Git merged four other files that both sides change, with no overlap: crates/core/src/expression/key_condition.rs, crates/engine/src/lib.rs, docs/differences-from-dynamodb.md and crates/engine/src/decimal_digits.rs, which both sides add with the same content.
Main is at 80490c6, 34 commits after the last merge. #567 is one of them, squashed into 97729ce, and this branch starts from the branch of #567. Three files conflicted, because this branch holds the commits of #567 and main holds the squash. For each file the merge takes the file of main and applies the change of this branch from 637e7a9 and 5569436 on top: - crates/core/src/expression/tokenizer.rs: is_ident_start accepts only a letter, with its doc comment. - crates/core/src/expression/tokenizer_tests.rs: the test of a name that starts with "_" replaces tokenize_underscore_ident. The two rows of a "_" after an unknown character go after the "\r" row of UNKNOWN_CHARACTER_ROWS, where this branch put them. - tests/test_expression_unknown_character.py: the file of main, which the commits of this branch do not change. Git merged two other files that both sides change, with no overlap: crates/engine/src/partiql/mod.rs and crates/engine/src/query.rs.
Main is at 14ade59. This branch last had main at 018715e, through fix/query-key-value-types. Since then, these eleven commits merged into main: #1280, #1009, #596, #1173, #398, #428, #544, #567, #584, #588 and #864. #544 is the squash of fix/query-key-value-types, which was the base branch of this PR. This branch already holds the last head of that branch, 31c5f3d. Main has the same version of each conflicted file as 31c5f3d. So each conflict hunk has the lines of #544 on one side. The other side has the change of this branch to the same lines. The merge keeps the version of this branch in each file: - crates/engine/src/query_key_values.rs: this branch makes two constants and four functions pub(crate) for the Scan checks, and re-exports three functions of unreadable.rs. It reads a number in Segment and TotalSegments as it reads one in Limit, with the dates in the doc comment of shape_fault_first. It passes validate_no_parameter_mix to unreadable_value_checks. - crates/engine/src/query_key_values/unreadable.rs: this branch makes three functions pub(crate). unreadable_value_checks takes the parameter mix check as a parameter, so this branch deletes the import of validate_no_parameter_mix. - crates/server/src/request_helpers.rs: this branch runs the Scan request checks before the IAM decision, as main does for Query. - tests/test_query_leading_keys_values.py: this branch moves the setup of TestLeadingKeysWithAnInvalidKeyValue to the base class ManagementPrincipals, which tests/test_scan_checks_before_authorization.py imports. Git merged crates/engine/src/lib.rs with no conflict. Main compiles three modules only off wasm32 (backup, import_export_io and private_fs), and adds the modules backup_requests and pre_dispatch. This branch adds the module scan_request and changes the doc comment of validate_enum_fields.
Main is at 14ade59. This branch last had main at 018715e, through fix/query-key-value-types. Since then, these eleven commits merged into main: #1280, #1009, #596, #1173, #398, #428, #544, #567, #584, #588 and #864. #544 is the squash of fix/query-key-value-types, which was the base branch of this PR. This branch already holds the last head of that branch, 31c5f3d. Main has the same version of each conflicted file as 31c5f3d. So each conflict hunk has the lines of #544 on one side. The other side has the change of this branch to the same lines. The merge keeps the version of this branch in each file: - crates/engine/src/query_key_values.rs: the dates and the order in the module and function doc comments, the call of validate_condition_value_numbers, and the two functions validate_condition_value_numbers and refuse_first_fault. - crates/engine/src/query_key_values/request_order_tests.rs: the import of Value and the test legacy_condition_values_get_the_number_check. - tests/test_query_key_value_types.py: the dates in the docstring, the nn_table fixture and the helpers eq, N1, KC_ABC and QF_BOB. The merge also keeps the rows k1 to k16, and nn_table in the tables fixture and the control test. Git merged crates/engine/src/lib.rs with no conflict. This branch changes that file only through the commits of #544, so the merged file is the file of main.
Main is at 14ade59. This branch last had main at 018715e, through fix/query-key-value-types. Since then, these eleven commits merged into main: #1280, #1009, #596, #1173, #398, #428, #544, #567, #584, #588 and #864. #544 is the squash of fix/query-key-value-types, which was the base branch of this PR. This branch already holds the last head of that branch, 31c5f3d. Main has the same version of each conflicted file as 31c5f3d. So each conflict hunk has the lines of #544 on one side. The other side has the change of this branch to the same lines. The merge keeps the version of this branch in each file: - crates/core/src/partiql/params.rs: this branch deletes the two base64 imports, because decode_base64 replaces check_base64. - crates/core/src/types/attribute_value.rs: this branch adds BASE64_TEXTS, decode_base64 and is_base64_refusal after the two constants that #544 makes public. - crates/core/src/types/mod.rs: this branch adds decode_base64 and is_base64_refusal to the names that #544 re-exports. - tests/test_query_leading_keys_values.py and tests/test_query_value_shapes.py: this branch moves _raw_query to tests/raw_signed_request.py as client_post, and calls client_post in its place. No other test file on main calls _raw_query. Git merged crates/engine/src/lib.rs with no conflict. Main compiles three modules only off wasm32 (backup, import_export_io and private_fs), and adds the modules backup_requests and pre_dispatch. This branch adds serialization_exception and calls it from deserialize_error.
The base merges main at 14ade59. That brings #544 as a squash and ten other commits: #1280, #1009, #596, #1173, #398, #428, #567, #584, #588 and #864. One file conflicted: crates/engine/src/import_export.rs. #1009 moves the body of handle_import_table to import_table in the new file crates/engine/src/import_export/files.rs. The wasm32 build replaces that file with a stand-in that refuses the operation. handle_import_table keeps the enabled check and calls files::import_table. This branch changes the body that #1009 moves. When read_items finds a line that it cannot read, the import keeps the items before that line. It counts the line as one error and reads no more of the file. The merge keeps the code of main in import_export.rs, with the doc comment of this branch on handle_import_table. It makes the three changes of this branch to the body in files.rs: - The variable read holds the result of read_items: the items and the line that the reader cannot read. - The loop takes the items, then that line. At that line it logs the line number and the fault, counts one error and ends the import. - The comment over the FAILED status adds the date 2026-11-22, for the lines that the import cannot read. The body of import_table in files.rs is now the same as the body of handle_import_table at the head of this branch. Git merged docs/manuals/07-upgrade-manual.md with no conflict. #398 adds its v1.1.0 entry at the top of "Behavior Changes by Release". This branch adds its v1.1.0 entry at the end of that section.
The base merges main at 14ade59. That brings #544 as a squash and ten other commits: #1280, #1009, #596, #1173, #398, #428, #567, #584, #588 and #864. The merge has no conflict. Git merged crates/engine/src/lib.rs, the one file with changes on both sides. Main compiles three modules only off wasm32 (backup, import_export_io and private_fs), and adds the modules backup_requests and pre_dispatch. This branch adds single_write_refusal after deserialize_error.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has two features (#468, #1009) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #503, #544, #567, #765 and #774, #588, #596, #690, #1144, #1173 and #1194, next to the existing entries for #398 and #526. The #526 entry now gives the old TransactWriteItems mismatch message, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has two features (#468, #1009) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194 and #1375, next to the existing entries for #398, #526 and #1166. The #526 entry now gives the old TransactWriteItems mismatch message, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker.
* chore(release): bump version to 1.1.0 Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker. * docs(upgrade): add the v1.1.0 entry of #1290, put #1349's in order #1290 merged after this branch was rebased. It changes the answer to a request with no Authorization header, so it gets a v1.1.0 entry. The merge of main put the #1349 entry after the #1523 entry. It moves to the place of its number, beside the new #1290 entry. --------- Co-authored-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
Changes since the last review
The last review, of 24 November, was on 251a89c. These commits follow it:
1 validation error detected:ends as an expected failure.unknown_characterin backticks. The module doc oftokenizer.rsuses a colon where it had a dash.tokenize_for_multibyte_utf8_does_not_paniccallstokenize_forwith theKeyCondition,ProjectionandUpdatekinds, the three kinds that production passes.near: "= é "for#v = éandnear: " é "foré. At 251a89c ExtendDB answered= éandé. Two rows in the unit table and two Scan filter rows in the wire tests cover this case.The new expected texts are the service's answers of 2026-11-24 in us-east-1. Each request went out twice and got the same answer both times.
What
A character outside the expression grammar, such as
é, now gets the syntax error DynamoDB gives, with the same token and window. The token is the character as sent. The window runs from the start of the previous token to the end of the next one. When no token comes before the character, the window starts at the start of the expression. When no token follows it, the window runs to the end of the expression. Both tokenizers follow this rule:ConditionExpressionon PutItem, UpdateItem, DeleteItem and TransactWriteItems,FilterExpressionon Scan and Query, andKeyConditionExpressionon Query. The key condition goes through the server'sdynamodb:LeadingKeysparse, which runs before the authorization decision for every caller.UpdateExpression,ProjectionExpressionand the engine's key condition parse.Not changed here
These differences from the service are on main and stay as they are:
#v = = é), the service reports that fault. ExtendDB reports the character, because it tokenizes the whole expression before parsing. UpdateItem:SET a = ((:v)) $gets the syntax error at$, where DynamoDB reports the redundant parentheses written before it #1037 tracks this order. Condition expressions: three shapes the service refuses or words differently (measured 2026-10-24) #501 and FilterExpression and ProjectionExpression syntax errors answer the parser's text, not the service's token and position #839 track the service's text for parser faults, and fix(expression): operator cap, syntax error wording, PutItem map keys #558 makes the change Condition expressions: three shapes the service refuses or words differently (measured 2026-10-24) #501 asks for.#or:followed by a character that cannot start a name keeps main's texts. The tokenizer behind condition and filter expressions answersempty name reference '#'andempty value placeholder ':'. The tokenizer behindUpdateExpression,ProjectionExpressionand the engine's key condition parse answersSyntax error; token: "#", near: "#", and the same with:. The service answerstoken: "#", near: "#é"by the same window rule. A#or:followed by a character that cannot start a name gets ExtendDB's own text, where DynamoDB answers a syntax error at the#or:#1419 tracks this.#v = 1: the service refuses a bare number as an operand. ExtendDB reads it as an attribute name. ExtendDB reads a number operand in a condition, filter or key condition as an attribute name, and DynamoDB refuses it #1420 tracks this in conditions, filters and key conditions, and UpdateItem parsesSET a = 1,if_not_exists()and arithmetic on a parenthesised+or-, which DynamoDB refuses as syntax errors #1025 tracksSET a = 1.; expression size: <n>on filter and condition expressions. ExtendDB does. The expression size error on FilterExpression and ConditionExpression appends the byte length, which DynamoDB leaves out #1421 tracks this.1 validation error detected:prefix the service adds on write paths. fix(core): refuse the list indexes DynamoDB refuses in expression paths #1095 adds it in front of the syntax errors of this PR._: the service ends the window after the_(#v = é _abcanswersnear: "= é _"). ExtendDB reads_abcas one name and answersnear: "= é _abc". ExtendDB accepts an attribute name that starts with an underscore in every expression, and DynamoDB refuses it as a syntax error #1018 tracks this, and fix(core): refuse a name that starts with an underscore in an expression #1131, which builds on this branch, fixes it.Not measured: the service's answer to a caller fenced by
dynamodb:LeadingKeysfor such a key condition. ExtendDB answers ValidationException underForAllValuesand AccessDeniedException underForAnyValue, with no items either way.Files
tokenizer.rspassed 600 lines with the fix, so the second commit moves its tests intotokenizer_tests.rswith no other change, using the#[path]pattern ofevaluator_tests.rs.tokenizer.rsis now 452 lines.Other PRs
git merge-tree --write-treeis clean against #558, #479 and #1095. #1131 builds on this branch. When it merges this branch,tokenizer_tests.rshas one conflict, because both add rows at the end of the same table. #511 is already on main. #558 builds the window for parser faults by the same rule, including the start of the expression when nothing comes before the fault. Itsnear_window(syntax_error.rs) reads the token spans after the tokenizer has run. The tokenizer stops at a character outside the grammar before it reads the next token, sonext_token_endhere scans the source for it. One function for both windows needs the tokenizer to record token spans, which neither PR does.Why
This PR began as a fix for a panic. The tokenizer behind condition and filter expressions sliced the input five bytes either side of the offending byte. When that range ended inside a multi-byte character (
#v = ééé,#v = 日本語), the slice panicked, the request task ended and the client saw the connection close. #791 has since fixed that panic on main. It moves both ends of the five-byte window out to character boundaries and reports the whole character as the token.The windows on main still differ from the service's. The condition and filter tokenizer answers five bytes either side of the character. The tokenizer behind
UpdateExpression,ProjectionExpressionand the engine's key condition parse answers the character with one byte after it as the window (near: "é",near: "$x").No issue tracks this window, so this PR closes none.
What the service answers
Measured on 2026-10-25 at 16:09, 16:34, 16:38, 16:43 and 16:54 UTC in us-east-1, on all five expression kinds. Each request went out twice and got the same answer both times. When the character is the first fault in the expression:
é,日,😀, or$,@and!for ASCII characters outside the grammar.#v = éééanswerstoken: "é", near: "= éé".abéc = :vanswersnear: "abéc".#v = é abcanswersnear: "= é abc".#v é<> :vanswersnear: "#v é<>".contains(#v, é)answersnear: ", é)".é = :vanswersnear: " é =".#v = \0x, with U+0000 before thex, answerstoken: "", near: "= x".Later measurements, each request twice with the same answer both times:
#v = é\tabcanswersnear: "= é\tabc"). The ten rows ofOPERATION_ROWScome from the same day.#v = éanswersnear: "= é "). A filter that starts with U+FEFF, the byte-order mark, gets this syntax error too: its token is U+FEFF, and its window is U+FEFF followed by#v.The merge with main
The merge of main (807937e) keeps this rule and drops main's five-byte window. #791 added three tests:
tokenize_multibyte_utf8_near_an_invalid_byte_does_not_panicstays as fix(core): keep the tokenizer's error context on character boundaries #791 wrote it. Its one window assertion,$ 日for the input$ 日, matches the measured rule.tokenize_reports_the_whole_invalid_characterkeeps its token assertion. Its window fora = échanges froma = éto= é, the window that the measured row for#v = égives.tokenize_ascii_error_context_is_five_bytes_either_side. It expects the windows(a) $ bforattribute_exists(a) $ b, and the measured rule answers) $ b.Testing done
crates/core/src/expression/tokenizer_tests.rs: one table test with 50 measured rows, run through both tokenizers. The test fails on each of these broken versions of the rule:tests/test_expression_unknown_character.py: 63 dual-target wire tests. They cover Scan and Query filters, and conditions on PutItem, UpdateItem, DeleteItem and the four TransactWriteItems kinds. Other rows cover Query key conditions, one of them on a global secondary index, and UpdateItem update expressions. The rest cover projections on GetItem, Query, Scan, BatchGetItem and TransactGetItems. The Query key condition rows include the shape that closed the connection before fix(core): keep the tokenizer's error context on character boundaries #791.On ade81dc, on 2026-11-24, against a SQLite debug build:
cargo +1.97.0 fmt --all -- --check: no changes.cargo +1.97.0 clippy --locked -p extenddb-core --all-targets -- -D warnings: no warnings.cargo +1.97.0 clippy --locked -p extenddb-core --all-targets -- -W clippy::pedantic: no warning on a line this PR adds. Three warnings stay intokenizer.rs, on lines that main has:too_many_lineson both tokenizers, and no# Errorssection ontokenize_for.cargo +1.91.1 check --locked -p extenddb-core --all-targets: no errors.cargo +1.97.0 test --locked -p extenddb-core --lib: 1146 passed, 1 ignored.tests/test_expression_unknown_character.py: 54 passed and 9 xfailed, and the server log has no panic. With--runxfail, each of the 9 differs from the service's text only by the count.tests/test_expression_error_prefix.py: 7 passed.tests/test_select_all_projected_attributes.py: 4 passed.let start = at;in the server, 57 of the 63 wire tests fail, the 9 PutItem, UpdateItem and DeleteItem rows among them. Against the same server, the file of 251a89c reports those 9 as XFAIL.On the merge commit 807937e, on 2026-11-05, against a SQLite debug build:
cargo +1.97.0 fmt --all -- --check: no changes.cargo +1.97.0 clippy --locked -p extenddb-core --all-targets -- -D warnings: no warnings.cargo test --locked -p extenddb-core --lib: 765 passed, 1 ignored.tests/test_expression_unknown_character.py, which had 50 tests at that commit: 50 passed, and the server log has no panic.On 2026-10-25, before #791 merged, against a SQLite release build:
cargo test -p extenddb-coreon stable (521 passed) and on 1.88.0 (520 passed).The full SQLite wire suite at the third commit had 2 failures, in
tests/test_gsi_async.py. That file starts a server from./target/release/extenddb, a path that did not exist in that run. main failed the same 2. CI runs the new file inrun-integration,run-integration-sqlite,mongodb-pytestandcassandra-pytest.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
The message of the syntax error for a character outside the grammar changes. Its
nearwindow is the service's, by the rule under What. Main answers five bytes either side of the character, or the character with one byte after it, as Why describes. The status, 400, and the error code,ValidationException, stay the same. A client that matches the old window text gets the new one.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.