Repository navigation
fix(core): refuse a name that starts with an underscore in an expression - #1131
LeeroyHannigan wants to merge 24 commits into
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.
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.
Amazon DynamoDB refuses an attribute name that starts with `_` when an expression writes it without a `#name` placeholder. Every expression member answers with a syntax error at the `_`. Its near text runs from the token before the `_` to the token after it. ExtendDB read `_x` as a name and served the request. A name now starts with a letter. The tokenizers refuse a `_` at the start of a name with the syntax error they write for other characters. An underscore after the first character, in a `#name` and in a `:value` is still part of the name. PutItem, UpdateItem and DeleteItem put `1 validation error detected: ` ahead of this refusal. Query, Scan, GetItem, BatchGetItem, TransactGetItems and TransactWriteItems send the syntax error alone. DynamoDB reads the key condition before it looks up the table. When a Query names a table that does not exist, ExtendDB now tokenizes the key condition before it reports the missing table. It refuses a `_` and an empty key condition there as DynamoDB does. Measured in us-east-1 on 2026-11-14 and 2026-11-18, each request twice. Fixes #1018.
The comment on the missing-table Query test said that Amazon DynamoDB does not check reserved words ahead of the table lookup. On a table that does not exist, DynamoDB refuses `status = :v` as a reserved word (measured 2026-11-19). The `size = :v` row gets ResourceNotFoundException because the service reads `size` as a name. The comment now states both facts.
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.
On a table that does not exist, Query tokenized the key condition but did not check its size first. A key condition of more than 4096 tokens got the token limit error. A key condition of more than 4096 bytes that the tokenizer accepts got ResourceNotFoundException. On a table that exists, parse_key_condition_expr runs the size check before the tokenizer. The missing-table branch now runs the same size check ahead of the tokenizer. On a table that does not exist, Amazon DynamoDB answers `Invalid KeyConditionExpression: Expression size has exceeded the maximum allowed size;`. It gives that answer to three key conditions of more than 4096 bytes. They are a key condition of 8203 tokens, `pk = :v` with 4100 spaces after it, and a 4100-byte name with ` = :v`. Each request went out twice, in us-east-1 on 2026-11-25. The Query test of a missing table has a row for each of them.
The wire test of a name that starts with `_` gets the rows below. Each expected answer is the answer of Amazon DynamoDB in us-east-1 on 2026-11-18, where each request went out twice. - A TransactWriteItems Put, Delete and ConditionCheck with `attribute_exists(_x)` get the syntax error with no count. - An UpdateItem `ConditionExpression` `attribute_exists(_x)` gets the count. - `a[1_]` gets `near: "1_]"` in a Query ProjectionExpression and in a PutItem ConditionExpression. - DynamoDB serves the PartiQL statements `SELECT _x, a._b` and `UPDATE ... SET _y = 1`. The module fixture writes the item that the UPDATE changes. The count depends on the call site, so the transaction rows fail if a transaction path starts to count the refusal. The test of a valid key condition on a table that does not exist now compares the message as well as the error code.
… name The engine unit test of a name that starts with `_` had an UpdateItem row that applied count_leading_underscore_refusal itself. Its TransactWriteItems row checked the output of parse_update_expr, which the fix does not change. A mutant that deletes the count from update_item.rs passes every engine unit test and fails the UpdateItem rows of the wire test. The unit test now keeps only the filter and PutItem condition rows. The tokenizer test loses a row that repeated the `_pk = :v` row of the key condition. The doc comment of count_leading_underscore_refusal now says that it counts a syntax error at a `_`. That covers `a[1_]` too.
navareamol
left a comment
There was a problem hiding this comment.
Findings below. This head does not build once main is merged, and the branch conflicts with main.
-
crates/engine/src/query.rs:23importscheck_expression_sizefromcrate::expression_helpers. Since main moved that function intoextenddb_core::expression,expression_helpers.rsonly imports it privately. I merged this head into main 222d80a locally and gotE0603: function import 'check_expression_size' is private, socargo test -p extenddb-engine --libdoes not compile. I think the fix is to import it fromextenddb_core::expressioninquery.rsand drop it from thecrate::expression_helperslist. With only that change on the merged tree, core lib passes (1241), engine lib passes (981), and the wire filestest_expression_leading_underscore.pyandtest_expression_unknown_character.pygive the same results as on this head (9 expected failures, none new). -
GitHub reports a conflict with main. It is one file,
crates/engine/src/partiql/test_context.rs: main rewrotecontext()to build the context throughcrate::test_context::context_on, and this PR changes the visibility of the old body. I think taking main's file and changingpub(super) async fn contexttopub(crate) async fn contextis enough. The line in the description that says git merges thetest_contextchange without a conflict is out of date after the merge. -
The red
wasmcheck on this head fails in "Build the adapter for wasm32" withE0308 mismatched types. #1482 fixed that on main on 25 November andwasm.ymlhas been green on main since. I think merging main clears it. The other checks ran before the 18 commits that main has gained, so they need a new run on the merged branch. The description line about applying the two commits of #1482 can go. -
On a table that does not exist,
QuerywithKeyConditionExpression: "pk = :v"andFilterExpression: "_x = :v"answersResourceNotFoundException, and so does the same request withProjectionExpression: "_x".Scanon a missing table with the same filter answers the syntax error, andQueryon an existing table answers the syntax error. The upgrade manual says the refusal holds in the filter and projection expressions, and the docstring oftests/test_expression_leading_underscore.pysays a filter is checked before the table lookup. Has anyone measured on the real service whatQueryanswers for a valid key condition plus a_filter on a missing table? If it answers the syntax error, I think the missing-table branch needs to scan the filter and projection too. If it answersResourceNotFoundException, I think the manual and the docstring should say that Query's filter and projection are not checked first.
The rest I checked and it holds on this head. I ran the PR's wire file on this head and on a build of main: 31 refusal rows fail on main and pass here, so that file detects the change. I reverted the fix, the size check, the key condition scan and each of the two counts, and a test fails for each of the first four. Removing the count in the UpdateItem update-expression parse leaves every engine unit test passing and fails 4 wire rows (update-set, update-nested, update-remove, update-missing-table), as the description says. Tables whose key and index attributes start with _, the legacy parameters (Expected, AttributeUpdates, KeyConditions, QueryFilter, ScanFilter, AttributesToGet) and PartiQL statements on those tables are still served.
I will approve once the import is fixed, main is merged with a green CI run, and finding 4 is answered or the text is changed to match the code.
Main is at c8e66fb. This branch last had main at 80490c6. Since then, 34 PRs merged into main, #1482 among them, which fixes the WebAssembly build. Two files conflicted: - crates/engine/src/partiql/test_context.rs: main builds context() through crate::test_context::context_on (#1449), and this branch makes the old function pub(crate) for the missing-table test of query.rs. The merge takes the file of main and makes context pub(crate). - docs/manuals/07-upgrade-manual.md: main added two v1.2.0 entries at the top of Behavior Changes by Release, where this branch added its v1.1.0 entry. The merge keeps the entries of main first, then the entry of this branch. #1449 moved check_expression_size from crates/engine/src/expression_helpers.rs to extenddb_core::expression, where crates/engine/src/expression_helpers.rs imports it privately. So crates/engine/src/query.rs now imports it from extenddb_core::expression. Without that change the engine does not build (E0603). Git merged expression_helpers.rs, partiql/mod.rs and query.rs with no other conflict.
… table On a table that does not exist, Query answered ResourceNotFoundException to a filter or a projection that names `_x`. DynamoDB answers the syntax error. Measured in us-east-1 on 3 Dec 2026, each request twice, with the key condition `pk = :v`: - FilterExpression `_x = :v`: `Invalid FilterExpression: Syntax error; token: "_", near: "_x"` - ProjectionExpression `_x`: `Invalid ProjectionExpression: Syntax error; token: "_", near: "_x"` - FilterExpression `a = @` and an empty FilterExpression get the tokenizer's other errors there too. With faults in two of them, the service answers the filter ahead of the key condition and the key condition ahead of the projection. The filter fault also comes ahead of a key condition over the size limit. When the table lookup fails, the handler now runs the tokenizer on the filter first. The size check and the tokenizer on the key condition come next, then the tokenizer on the projection. A table that exists keeps the order of the checks. The engine test of a missing table and tests/test_expression_leading_underscore.py get a row for each request.
The v1.1.0 release of 27 Nov 2026 does not include this change. Its entry in the upgrade manual is now a v1.2.0 entry, after the two v1.2.0 entries of main. The entry names 1.1.0 as the release that served such a name. It also names the Query filter and projection, which a table that does not exist now checks too. The entry gets the PR and the issue numbers, as the other entries have.
|
|
Points 1 to 4 of my review are resolved on 9e475b4. origin/main is an ancestor of the head, so there is no conflict and no import error. Core lib passes (1260), engine lib passes (984), the two wire files give 100 passed and 9 expected failures, and wasm, clippy and fmt are green. On a missing table the filter, then the key condition, then the projection answer in the order you measured. The upgrade manual entry under v1.2.0 matches the code. I found two things left.
I will approve once the first question is answered and the checks that are still running finish green. |
… a missing table On a table that does not exist, Query answered ResourceNotFoundException to a filter or a projection over 4096 bytes. DynamoDB answers the size error. Measured in us-east-1 on 4 Dec 2026, each request twice, with the key condition `pk = :v`: - FilterExpression `a = :v` and 4100 spaces: `Invalid FilterExpression: Expression size has exceeded the maximum allowed size;` - ProjectionExpression `a` and 4100 spaces: `Invalid ProjectionExpression: Expression size has exceeded the maximum allowed size;` The size error also comes ahead of the `_` refusal in the same member, and the filter size error ahead of a key condition `_g = :v`. The key condition `_g = :v` comes ahead of an oversize projection. Scan of a table that does not exist sent the filter size error with no `expression size` suffix too. When the table lookup fails, the handler now checks the filter, then the key condition, then the projection. Each one gets the size check, then the tokenizer. The filter check uses ExpressionKind::Filter, so size_error_includes_length no longer includes Filter. No other caller checks the size as Filter: the filter parse checks it as Condition and keeps the suffix (#1421). The engine test of a missing table gets four rows. The wire file tests/test_expression_leading_underscore.py gets three: the two size rows and the key condition ahead of the projection.
Main is at 5826e1b. This branch last had main at c8e66fb. Since then, four PRs merged into main: #1446, #1531, #1466 and #1087. One file conflicted. In docs/manuals/07-upgrade-manual.md, #1087 added its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. The merge keeps the entries of main first, then the entry of this branch. Main changed no other file that this branch changes.
With the four rows of a6bf351, the test of a Query on a missing table is 113 lines long. clippy::too_many_lines (pedantic) warns over 100 lines. The function holds one row per measured request, so it allows the lint, as crates/core/src/backup_format/golden_tests.rs does for its pinned lists.
… length The doc of check_expression_size still named Filter and Condition as the kinds whose size error carries the byte length. Since a6bf351, only Condition does.
The checks at 9e475b4 finished with 75 of 75 passed. dd08869 merges main at 5826e1b, where #1087 put a manual entry at the place of this PR's entry, and the merge keeps both. ca7645b allows |
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at 69e81e3. 1 finding: 1 Docs.
The change makes the expression tokenizer refuse a name that starts with _ (syntax error at the _, with the 1 validation error detected: prefix on PutItem, UpdateItem and DeleteItem conditions and UpdateItem update expressions), and makes Query check filter, key condition and projection size and tokens before reporting a missing table. Confirmed: the PR's dual-target wire file passes 49 of 49 on ExtendDB (SQLite) and 41 of 41 runnable rows pass on live DynamoDB (the 8 others are request shapes the live wrapper refuses); 37 extra probes (Query, Scan, GetItem, UpdateItem, PutItem and DeleteItem on existing and missing tables, with _ in functions, IN, BETWEEN, NOT, REMOVE, ADD, DELETE and legacy parameters) matched DynamoDB except the documented bare # and : windows and the size suffix. Putting back _ in is_ident_start, the Filter suffix, the PutItem count and the Query projection check each fails a test. Merged with current main (44a7b79) the tree builds and core (1260) and engine (984) lib tests pass under 1.94.0.
- Docs
crates/core/src/expression/kind.rs:41— The doc says a filter parsed asConditionkeeps; expression size: Nas DynamoDB sends it, but live DynamoDB sends no suffix for a Query or Scan filter on an existing table, and the head still appends it.
|
|
||
| /// Whether the size-limit error appends `; expression size: N`. Amazon | ||
| /// `DynamoDB` appends it for `Filter` and `Condition` only. | ||
| /// Whether the size-limit error appends `; expression size: N`. It does for |
There was a problem hiding this comment.
Docs
The doc comment at kind.rs:41-47 and the body ("The filter parse on a table that exists checks it as Condition and keeps the suffix (#1421)") say DynamoDB's size error carries ; expression size: N for a filter that parse_condition_expr reads. I sent a 4106-byte filter (a = :v + 4100 spaces) to DynamoDB in us-east-1 on 2026-12-04: Query on an existing table, Query on a missing table and Scan on an existing table all answered Invalid FilterExpression: Expression size has exceeded the maximum allowed size; with no suffix. The head answers Scan with ... maximum allowed size; expression size: 4106 on both an existing and a missing table, so it also differs from the body's own statement that a Scan of a missing table gets no suffix.
Fix: reword the doc and the body so they do not claim the suffix is DynamoDB's for a filter, or drop Condition and the relabel inheritance from the set and measure each operation's condition separately; tests/test_expression_leading_underscore.py and query_missing_table_tests.rs:136 pin the current text and change with it. Only the wording is this PR's; the suffix behaviour on Scan and existing-table Query predates it.
Evidence: kind.rs:47 reads matches!(self, Self::Condition). On DynamoDB, PutItem with a 4107-byte ConditionExpression also answered 1 validation error detected: Invalid ConditionExpression: Expression size has exceeded the maximum allowed size; with no suffix, while the head answers ... size; expression size: 4107 without the count prefix.
There was a problem hiding this comment.
Fixed in a6bdace. The doc now names check_expression_size as the source of the error. It says that Amazon DynamoDB left the suffix out of the filter and condition errors that #1421 measured. In the description, What now says that ExtendDB keeps the suffix for a filter on a table that exists, and that #1421 tracks the difference.
On Scan, the description gives two answers. Why gives DynamoDB's answer to a Scan of a table that does not exist, with no suffix, and that sentence now names DynamoDB. Not in this PR gives ExtendDB's answer there, with the suffix (#1421), and the head sends that. Not in this PR now also says that a Query or a Scan filter on a table that exists gets the suffix.
The behaviour stays as it is. As you say, the suffix on Scan and on a Query of a table that exists predates this PR. #1421 proposes to drop it for every kind. Your PutItem request is the second row of #1421, which also names the missing count.
The doc of size_error_includes_length did not say whose error appends `; expression size: N`, so it could read as the service's text. It now names check_expression_size, and it says that Amazon DynamoDB left the suffix out of the filter and condition errors that #1421 measured.
Changes since the last review
LJMart11 reviewed 69e81e3 on 4 December. One commit comes after that review:
size_error_includes_lengthincrates/core/src/expression/kind.rs. The doc now namescheck_expression_sizeas the source of the error. It says that Amazon DynamoDB left theexpression size: Nsuffix out of the filter and condition errors that The expression size error on FilterExpression and ConditionExpression appends the byte length, which DynamoDB leaves out #1421 measured. In this description, What, Why and Not in this PR now say whose answer each sentence on the suffix gives. Testing done gives the checks on a6bdace.navareamol reviewed 9e475b4. These commits came between that review and the review of 69e81e3:
handle_querynow checks the filter, then the key condition, then the projection. Each one gets the size check and then the tokenizer. The filter's size error there has noexpression sizesuffix, as on DynamoDB. The engine test of a missing table gets four rows.tests/test_expression_leading_underscore.pygets the two size rows and a row with_g = :vand the projection_x.mainat 5826e1b, four PRs after the last merge. One file conflicted. Indocs/manuals/07-upgrade-manual.md, fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 added its v1.2.0 entry where this PR has its entry. The merge keeps the entries of main first.clippy::too_many_lineson the missing-table test. The four new rows take its data table to 113 lines, and the pedantic lint warns over 100. The function holds one row per measured request.check_expression_sizeincrates/core/src/expression/kind.rs. It still namedFilterandConditionas the kinds whose size error carries the byte length. Since a6bf351, onlyConditiondoes.Please use the PR title and the What section as the squash message when this PR merges. GitHub's commit list of this PR holds the eight commits of #567, which
mainalready has as the squash 97729ce.What
ExtendDB now refuses an attribute name that starts with
_when an expression writes it without a#nameplaceholder, as Amazon DynamoDB does. Every expression member answersInvalid <member>: Syntax error; token: "_", near: "<text>". Before this change ExtendDB read_xas a name and served the request.is_ident_startin the tokenizer now accepts only a letter. A_at the start of a name reaches the tokenizer's arm for a character outside the grammar. #567 gives that arm DynamoDB's window, from the start of the previous token to the end of the next one. An underscore after the first character, in a#nameand in a:valueis still part of the name.PutItem, UpdateItem and DeleteItem put
1 validation error detected:ahead of this refusal. The other operations, TransactWriteItems included, send it alone.count_leading_underscore_refusaladds the count where the single-item writes parse: inresolve_conditionand in the UpdateExpression parse of UpdateItem.A Query of a table that does not exist now checks its expressions before it reports the missing table. It checks them in DynamoDB's order: the filter, then the key condition, then the projection. On each one, it runs the size check and then the tokenizer. These are the first two steps of the parse of each member on a table that exists. A member over 4096 bytes gets the size error. An expression that the tokenizer refuses gets the tokenizer's answer. That covers a
_at the start of a name, a character outside the grammar, a bare#or:and an empty expression.The filter's size error on a missing table has no
expression size: <n>suffix, as on DynamoDB.handle_querychecks it asExpressionKind::Filter, sosize_error_includes_lengthno longer includesFilter. No other code checks a size asFilter. On a table that exists, the filter parse checks the size asCondition, and ExtendDB keeps the suffix there. DynamoDB left the suffix out of the errors that #1421 measured, and #1421 tracks the difference.With this order,
pk = égets DynamoDB's answer,Syntax error; token: "é", near: "= é". A bare#getsnear: "#", where DynamoDB answersnear: "= #"(#1419). The other faults keep the missing-table answer.The same
is_ident_startchange answers a comment on #567 about the window after a leading_.#v = é _abcand#v = é __xnow getnear: "= é _".count_leading_underscore_refusalis a second copy of a count that two open PRs add in the same two places: #1095 (count_list_index_refusal) and #399 (single_item_write_prefix). Both of them count every syntax error of the single-item writes. This PR keeps its own copy, because it can merge before them. When one of them merges, this PR drops its copy.#567 merged into
mainon 25 November as 97729ce, and its branchfix/tokenizer-multibyteis gone. This PR targetsmain.Why
These are DynamoDB's answers, measured in us-east-1. The rows of the issue date from 14 November 2026. On 18 November 2026, more requests went to DynamoDB, and each one went out twice with the same answer both times:
attribute_exists(_x)gets the syntax error with no count. An UpdateItemConditionExpressiongets the count.a[1_]getsnear: "1_]"in a ProjectionExpression and in a ConditionExpression._g = :vgets the syntax error, and an empty key condition getsInvalid KeyConditionExpression: The expression can not be empty;. The key conditionsize = :vgetsResourceNotFoundException.a_b,#_xand:_vin every expression of every operation, and the PartiQL statements keep their answers.#v = é _abcor#v = é __xgetsnear: "= é _".On 25 November 2026, more Query requests went to a table that does not exist, each one twice with the same answer both times:
Invalid KeyConditionExpression: Expression size has exceeded the maximum allowed size;:(, thenpk = :v, then 4100). This key condition is over the token limit too.pk = :v, then 4100 spaces.= :v.pk = égetsInvalid KeyConditionExpression: Syntax error; token: "é", near: "= é", andpk = #getsInvalid KeyConditionExpression: Syntax error; token: "#", near: "= #".On 3 December 2026, these Query requests went to a table that does not exist, each one twice with the same answer both times. Each one has
ExpressionAttributeValues{":v": {"S": "x"}}:pk = :v_x = :vInvalid FilterExpression: Syntax error; token: "_", near: "_x"pk = :v_xInvalid ProjectionExpression: Syntax error; token: "_", near: "_x"pk = :va = @Invalid FilterExpression: Syntax error; token: "@", near: "= @"pk = :vInvalid FilterExpression: The expression can not be empty;_g = :v_x = :v_g = :v_xInvalid KeyConditionExpression: Syntax error; token: "_", near: "_g"pk = :v_x = :v_ypk = :vand 4100 spaces_x = :vA Scan with the filter
_x = :von a table that does not exist getsInvalid FilterExpression: Syntax error; token: "_", near: "_x"too.On 4 December 2026, these Query requests went to a table that does not exist, each one twice with the same answer both times. They have the same
ExpressionAttributeValues. "+ 4100 spaces" means the text and then 4100 spaces, over the limit of 4096 bytes:pk = :va = :v+ 4100 spacesInvalid FilterExpression: Expression size has exceeded the maximum allowed size;pk = :va+ 4100 spacesInvalid ProjectionExpression: Expression size has exceeded the maximum allowed size;pk = :v_x = :v+ 4100 spacespk = :v_x+ 4100 spaces_g = :va = :v+ 4100 spaces_g = :va+ 4100 spacesInvalid KeyConditionExpression: Syntax error; token: "_", near: "_g"pk = :v+ 4100 spacesa+ 4100 spacesInvalid KeyConditionExpression: Expression size has exceeded the maximum allowed size;pk = :va = :v+ 4100 spaces_xpk = :vaand 4096z, then= :v_g = :v_xInvalid KeyConditionExpression: Syntax error; token: "_", near: "_g"DynamoDB also sent the filter's size error with no suffix to a Scan of a table that does not exist. Its filter was
a = :v+ 4100 spaces, or the 4102-byte filter of the long name.Closes #1018
Not in this PR
pk = :v OR pk = :w. On a table that does not exist, these faults getResourceNotFoundException, and DynamoDB answers the fault (Query looks up the table, the index and ConsistentRead before it checks the expressions, and reads the key condition before the filter #1208). Open PR fix(expressions): validate in the service's order, with its messages #399 moves those checks ahead of the lookup.pk = #getsnear: "#", and DynamoDB answersnear: "= #". On main it gotResourceNotFoundException. 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 the window of a bare#and:.The table does not have the specified indexahead of the_refusal, as on main. DynamoDB answered the syntax error on 18 November 2026. Query looks up the table, the index and ConsistentRead before it checks the expressions, and reads the key condition before the filter #1208 tracks this order, and open PR fix(expressions): validate in the service's order, with its messages #399 parses the key condition ahead of both lookups.expression size: <n>, where DynamoDB sends no suffix (The expression size error on FilterExpression and ConditionExpression appends the byte length, which DynamoDB leaves out #1421). A condition over 4096 bytes gets the suffix too, and DynamoDB left it out on a PutItem of a table that does not exist (The expression size error on FilterExpression and ConditionExpression appends the byte length, which DynamoDB leaves out #1421). On a table that exists, a Query or a Scan filter over 4096 bytes gets the suffix too.sizeas a name in a key condition and a condition (ProjectionExpression and UpdateExpression refusesizeas a reserved word where it names an attribute, and DynamoDB reads it as a name #1028).Other open PRs
expression_helpers.rsandupdate_item.rs. The resolution takes fix(core): refuse the list indexes DynamoDB refuses in expression paths #1095's lines and dropscount_leading_underscore_refusal.expression_helpers.rs,query.rsandupdate_item.rs. fix(core): refuse a document path of more than 32 elements #597 and fix(core): report the first ProjectionExpression fault in written order #1140 build on the branch of fix(expressions): validate in the service's order, with its messages #399. The resolution takes theirhandle_queryand drops this PR's lookup-failure branch. It takes their lines inresolve_conditionandupdate_item.rs, whosesingle_item_write_prefixcounts the_refusal. fix(expressions): validate in the service's order, with its messages #399 also changescheck_expression_sizeincrates/core/src/expression/kind.rs, and git merges that file with this PR's change with no conflict.partiql::test_contextand itscontextfunctionpub(crate)with the same lines. feat(storage): carry ConsistentRead to the data engine as ReadOptions #559 makes the modulepub(crate)with the same line and leavescontextas it is.docs/manuals/07-upgrade-manual.md, fix(server): send Message on a SerializationException #1220 among them. The PR that merges second keeps both entries.Testing done
The runs below are on ca7645b. The wasm-adapter tests, the docs test, the WebAssembly clippy step and the PostgreSQL wire run are on dd08869. ca7645b adds only the lint attribute to a test. 69e81e3 changes one line of a doc comment, and
cargo +1.97.0 fmt --all -- --checkis clean on it. a6bdace changes five lines of a doc comment. On it,cargo +1.97.0 fmt --all -- --checkis clean, andcargo +1.97.0 clippy -p extenddb-core --all-targets -- -W clippy::pedanticgives no warning inkind.rs.cargo test -p extenddb-core --lib: 1260 passed, 1 ignored.cargo test -p extenddb-engine --lib: 984 passed.cargo test -p extenddb-wasm-adapter, itsparitycorpus test included: 4 passed.cargo +1.97.0 fmt --all -- --checkis clean. Both clippy commands of.github/workflows/clippy.ymlwith-D warningsare clean onextenddb-coreandextenddb-engine, and so iscargo +1.94.0 check --all-targetson the same crates.cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -W clippy::pedanticgives no warning on a line that this PR adds..github/workflows/wasm.ymlis clean.cargo test -p extenddb-storage-postgres --test doc_version_literals: passed.tests/test_expression_leading_underscore.py,tests/test_expression_unknown_character.pyandtests/test_expression_size_limit.pygive 110 passed and 9 expected failures against a SQLite server, and the same against a PostgreSQL server. The 9 are the rows of fix(expression): report a character outside the grammar without closing the connection #567 for the count that ExtendDB leaves out. The three new rows pass.--collect-onlycollects 7390 tests intests/and 820 intests/python, with no error.query.rsof 9e475b4, the engine test fails at its first size row, which gets the filter's syntax error. On a SQLite server, the two size rows oftests/test_expression_leading_underscore.pyfail, and the other 47 tests of the file pass.kind.rsof 9e475b4, the engine test fails at the same row, whose answer ends in; expression size: 4107.Line counts over
main: production +77 -16, tests +493 -12, and 6 added lines of the upgrade manual. Production is the Rust code outside test modules. Counted the same way at 9e475b4, they were production +67 -9 and tests +448 -12. a6bdace replaces five doc lines that this PR adds, so the counts do not change with it. The last description gave production +73 -9 by another count.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
An expression that writes an attribute name that starts with
_without a#nameplaceholder now getsValidationException, as on DynamoDB, where main served it. A request can still use such a name throughExpressionAttributeNames.On a table that does not exist, a Query now gets
ValidationExceptionwhen its key condition, its filter or its projection is over 4096 bytes. It also gets it when the tokenizer refuses its filter, its key condition or its projection. Main answeredResourceNotFoundException.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.