Repository navigation
fix(core): report the first ProjectionExpression fault in written order - #1140
LeeroyHannigan wants to merge 6 commits into
Conversation
Amazon DynamoDB checks the paths of a ProjectionExpression in written order. A path reports its first faulty element, and an overlap is a fault of the later path. ExtendDB checked every token for a reserved word before it read any path. So it named the reserved word for "#u, name", "a, a.b, name", "#u.name" and "name, a..b". The reserved word check now runs where Projection::compile resolves each path, element by element. A bare name is checked before the next element is resolved. So "#u.name" names #u, and "name.#u" still names the reserved word. A syntax error now comes before the check. The callers pass enforce_reserved_keywords to Projection::compile. UpdateExpression paths keep their check on the token stream. DynamoDB gave these answers on GetItem on 2026-11-14, and on GetItem, Query, Scan, BatchGetItem and TransactGetItems on 2026-11-18. Fixes #1024.
Each read handler and the PartiQL transaction read pass enforce_reserved_keywords. The PartiQL RETURNING projection passes false, because all its names are placeholders. No test sent Scan, BatchGetItem or SearchVectors a projection that DynamoDB answers with the reserved word. So no test failed when one of those handlers passed false. The name.#u row now goes to GetItem, Query, Scan, BatchGetItem and TransactGetItems. The vector projection test sends it to SearchVectors. DynamoDB answered the reserved word for it on GetItem and Query on 2026-11-18, and on Scan, BatchGetItem, TransactGetItems and SearchVectors on 2026-11-24. _validation_message now also checks the HTTP status 400. The module docstring no longer names the AWS CLI as the source of the messages.
…exts The engine table now holds the three rows with a path of 33 elements. For a path of 33 elements and then the path name, ExtendDB now answers the path length text. The token check of the base answered the reserved word. The path name and then a path of 33 elements, and a path of 33 elements with .name after them, answer the reserved word. DynamoDB gave these answers on GetItem on 2026-11-18. The syntax rows now compare ExtendDB's own parser text by equality. So an undefined name or an overlap answer fails them. The service words a syntax error differently (#839). The doc comment of the test lists the reads that went to DynamoDB for each row.
docs/dynamodb-limits.md said that ExtendDB checks reserved words on the whole expression before any path, for every expression kind. That is no longer true for a ProjectionExpression: it checks them in the same walk as its paths, as the service does. The other kinds keep the check on the whole expression. In the doc comments, resolve_paths now names its reject_reserved check, and Projection::compile writes DynamoDB in backticks, as the clippy doc_markdown lint asks.
navareamol
left a comment
There was a problem hiding this comment.
I ran
#u.nameagainst all five reads on this branch and on #597. This branch answers the undefined#uon all five, and #597 answers the reserved word on all five. The test pins it only for GetItem (FIRST_FAULT_GET_ITEM), while the description says it was measured on GetItem, Query, Scan and TransactGetItems. Could you move it toFIRST_FAULT_ALL_READS, or add the three measured reads? BatchGetItem is not in the measured list for this row, so I think it needs a measurement or should be left out.In
docs/dynamodb-limits.md, the old text said the service checks reserved words in the same walk as the paths. The new text says ExtendDB checks them on the whole expression for the other kinds, but no longer says what the service does for those kinds. Was the service's order for, say, a ConditionExpression measured? If it was, I think the clause should stay so the row still shows the difference. If not, could the row say it was not measured?
member_projectioninpartiql/transaction.rsrenders every path throughExprBridge::path, which gives each name a#nplaceholder, so the bare name check never fires there. That is the same reason RETURNING passesfalse. Passingenforce_reserved_keywordsis harmless, but the description reads as if it changes something. Could you passfalsewith the RETURNING comment, or reword that line?A question on a shape the table does not cover: when a later path both overlaps an earlier one and holds a reserved word, as in
a, a.name, this branch answers the reserved word, because the check runs on each element before the overlap check. Has anyone measured what DynamoDB answers for that?A note on the base:
git merge-treeof this head with current main conflicts in 11 files. The same 11 conflict for #597's head, and #399 shows DIRTY, so this comes from main moving under #399 and #597, not from these commits. The green CI ran on the merge with the #597 branch.I will approve once
#u.nameis pinned on the measured reads and the doc row says what the service does for the other kinds.
The #u.name row was in FIRST_FAULT_GET_ITEM, so only GetItem sent it. On 3 December 2026 DynamoDB answered the undefined #u text for #u.name on GetItem, Query, Scan, BatchGetItem and TransactGetItems. The row now sits in FIRST_FAULT_ALL_READS. In a, a.name the later path overlaps the earlier one and holds a reserved word. The five reads answered the reserved word text on the same day, and ExtendDB gives the same answer. That row goes into FIRST_FAULT_ALL_READS too. Each request went to a table name that does not exist, twice, with the same answer both times.
The document path length row said what ExtendDB does for the other expression kinds, but not what the service does. On 3 December 2026 the service got a path of 33 elements followed by name in four kinds: ConditionExpression, FilterExpression, KeyConditionExpression and UpdateExpression. It answered the length error for all four, and ExtendDB answers the reserved word error. The row now states both orders.
|
navareamol
left a comment
There was a problem hiding this comment.
@LeeroyHannigan points 1, 2, 3 and 5 are resolved at 1bc6167, and point 4 is answered for a, a.name.
-
#u.nameis inFIRST_FAULT_ALL_READSnow, so all five reads send it. On a SQLite server, the ten wire files from your description pass on this head (557 passed with my extra cases, 505 without them). On #597's head (7029242) the same files fail intest_first_fault_in_written_orderfor#u, name,#u.nameanda, a.b, nameon all five reads. That is the 15 of 37 cases you give. Thea, a.namerows pass on #597 too, so they guard the answer and do not detect this change. Your BatchGetItem measurement of 3 December is yours and I did not repeat it. -
The doc row now says the service checks reserved words in the same walk for the other kinds and that ExtendDB checks the whole expression first. I checked the ExtendDB half on this head: a 33 element path followed by
attribute_exists(name)answers the reserved word in a ConditionExpression and a FilterExpression, and the same in an UpdateExpression withSET <33 elements> = :v, name = :v. #597 gives the same answers, so the row describes behaviour that was already there. I did not send a reserved word after a long path in a KeyConditionExpression. The service half of the sentence is your measurement. -
I read the description. It now says the argument changes no answer in the two PartiQL projections, and the code did not change, so the text matches the code.
SELECT "name", "size"through ExecuteStatement and ExecuteTransaction gives the same answer on this head and on #597. -
a, a.nameanswers the reserved word on all five reads on this head, and on #597 as well, so this PR does not change it. The service answer is your measurement. Forl[0], l[0].nameI also get the reserved word on this head and on #597. Your reply names onlya, a.name. Is the service answer forl[0], l[0].namethe same? I do not ask for a change. -
I get the same conflict lists as you. Against main at db8a90d, this head and #597's head conflict in the same 12 files, among them
update_parser.rs(deleted here, modified on main). Against #399's head edb464c both conflict inevaluator.rs,evaluator_tests.rsandexpression_helpers.rs.
I ran SQLite only here. The service statements in the description and in your reply are your measurements.
Points 1, 2, 3 and 5 are resolved and point 4 is answered, so I approve. The merge to main waits for #399 and #597 to be updated with main.
Changes since the last review
#u.namerow oftest_first_fault_in_written_ordertoFIRST_FAULT_ALL_READS, so all five reads send it. It also adds the rowa, a.namethere. DynamoDB answered both rows on all five reads on 3 December.docs/dynamodb-limits.mdthat the service checks reserved words in the same walk for the other expression kinds too (measured on 3 December).enforce_reserved_keywordsargument changes no answer in the two PartiQL projections.What
ExtendDB now reports the first fault of a
ProjectionExpressionin written order, as DynamoDB does. It checks each path in turn. A path reports its first faulty element, and an overlap is a fault of the later path.Before this change, ExtendDB checked every token for a reserved word before it read any path. So
#u, name,a, a.b, nameand#u.namegot the reserved wordname, where DynamoDB names the first fault. On origin/main,a.b, c.d, c, aalso names the pair[a, b], [a], where DynamoDB names[c, d], [c]. #597 fixes that pair: it checks each path against the earlier paths inresolve_paths. This PR builds on #597 and adds these changes:resolve_pathschecks a bare name for a reserved word in itsPathElement::Attributearm, before it resolves the next element. So#u.namenames#u, andname.#unamesname.Projection::compiletakes a fourth argument,reject_reserved. Each read handler passesenforce_reserved_keywords. The two PartiQL projections give every name a placeholder:#nin the transaction read and#pin RETURNING. So the argument changes no answer there. The transaction read passesenforce_reserved_keywords, and RETURNING passesfalse. The UpdateExpression caller ofresolve_pathspassesfalse, so UpdateExpression paths keep their check on the token stream.parse_projection_exprno longer checks the token stream for reserved words, so a syntax error comes first.validate_not_reservedwrites the reserved word text for both checks.docs/dynamodb-limits.mdnow says that a ProjectionExpression checks its reserved words in the same walk as its paths, as the service does. For the other expression kinds, the row now says that the service checks them in the same walk too. ExtendDB keeps the check on the whole expression there.Why
These are DynamoDB's answers, measured in us-east-1 on 14, 18 and 24 November and 3 December 2026. Each request went out twice and got the same answer both times. On each row, every read in the last column gave the same answer.
ProjectionExpressionInvalid ProjectionExpression:#u, nameAn expression attribute name used in the document path is not defined; attribute name: #ua, a.b, nameanda, a.b, #uTwo document paths overlap with each other; must remove or rewrite one of these paths; path one: [a], path two: [a, b]a.b, c.d, c, apath one: [c, d], path two: [c]#u.name#utextname.#uAttribute name is a reserved keyword; reserved keyword: namea, a.namename, #uanda, name, a.bname, a..b,a..b, nameanda[name]Syntax error; token: ...a..b, nameon TransactGetItems on 24 Novnamename, then a path of 33 elements.nameafter themCloses #1024
Not in this PR
Each of these is in an issue:
a.b, a.c, a, DynamoDB names the second earlier path,[a, c]. fix(core): refuse a document path of more than 32 elements #597 and this PR name[a, b].expected numeric index in bracketsfora[name].ProjectionExpressionafter it looks up the table. So on a table that does not exist, it answersResourceNotFoundException, where DynamoDB answers the projection'sValidationException. origin/main has the same order. The new SearchVectors row of this PR goes to a table that exists.#name, an undefined:valueor a wrong operand type written before it #1031, Query reports OR and a reserved word in a KeyConditionExpression ahead of an undefined value #1007 and FilterExpression, ConditionExpression, KeyConditionExpression and UpdateExpression: ExtendDB reports a reserved word ahead of a long path written before it #1567: the other expression kinds keep the token check. So ExtendDB reports a reserved word ahead of a fault in an earlier path. For example, the ConditionExpressionattribute_exists(<33 elements>) AND attribute_exists(name)answers the length error on the service and the reserved word on ExtendDB (measured on 3 December). The row indocs/dynamodb-limits.mdstates this.Conflicts
This PR adds no conflict with any open PR. 58 open PRs change its files, and each of them conflicts with this head in the same files as with #597's head (
git merge-tree, 3 December). #1543 changesresolve_paths, to which this PR adds an argument, and it already conflicts with #597 inprojection.rs.Against main at
c057660361, this head and #597's head conflict in the same 12 files. Against #399's headedb464c7da, which merged that main, both conflict inevaluator.rs,evaluator_tests.rsandexpression_helpers.rs.Testing done
All runs are on
1bc616769a, except where a line namese1a5f1bfd. The two commits have the same Rust code, and both servers are builds ofe1a5f1bfd.cargo test -p extenddb-core --lib: 1157 passed, 1 ignored.cargo test -p extenddb-engine --lib: 878 passed.cargo clippy --all-targets --features extenddb-storage-cassandra/test-hooks,extenddb-storage-mongodb/test-hooks -- -D warnings,cargo clippy --all-targets --features extenddb-engine/backup-test-hooks -- -D warnings,cargo fmt --all -- --checkandcargo +1.94.0 check -p extenddb-core -p extenddb-engine --all-targets. With-W clippy::pedanticon the two crates, no warning is on a line that this PR adds.tests/test_projection_overlapping_paths.py,tests/test_nested_projection.py,tests/test_expression_error_prefix.py,tests/test_validation_precedence.py,tests/test_document_path_length.py,tests/test_item_operations.py,tests/test_query_scan.py,tests/test_transact_expression_validation.py,tests/test_transact_update_remove_only.pyandtests/test_transact_validation_order.py. The new testtest_first_fault_in_written_ordersends 7 rows to all five reads and 2 more expressions to GetItem.the_vector_attribute_is_returned_only_when_namedintests/rustpassed withEXTENDDB_EXPECT_VECTORS=1.test_first_fault_in_written_orderfails 15 of its 37 cases:#u, name,a, a.b, nameand#u.nameon all five reads.projection_reports_the_first_fault_in_written_orderholds every row above excepta, a.name. Ate1a5f1bfd, with the token stream check of fix(core): refuse a document path of more than 32 elements #597 put back, it fails on its first row. With the same check and the three rows of 33 elements first, it fails on the path of 33 elements and thenname.e1a5f1bfd, withfalsepassed at the Scan, BatchGetItem, TransactGetItems and SearchVectors callers, thename.#ucases of Scan, BatchGetItem and TransactGetItems fail. The SearchVectors test fails too.python3 -m pytest --collect-onlycollectstests/(7032 tests) andtests/python(672 tests) with no error.Line counts against #597: production +59 -22, tests +155 -6, docs +1 -1. The
#[cfg(test)]helperapply_projectioncounts as tests.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
A
ProjectionExpressionwith more than one fault now answers the fault that DynamoDB answers: a syntax error first, then the first fault in written order. Before, a reserved word anywhere in the expression answered first. The status 400 and the error codeValidationExceptiondo not change.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.