Repository navigation
fix(expressions): list elements set past the end append in order of their index - #103
Merged
kalaspuff merged 3 commits intoOct 30, 2026
Merged
Conversation
…heir index
The update evaluator assigned SET actions in the order of the
expression, and an index at or past the end of a list appends. So
`SET l[4] = :b, l[3] = :a` on `[x, y, z]` appended `b` at index 3 and
then overwrote it with `a`, storing `[x, y, z, a]`, and
`SET l[9] = :b, l[5] = :a` stored `b` before `a`. DynamoDB sets the
elements of a list in order of their index ("If you add multiple
elements in a single SET operation, the elements are sorted in order by
element number", the update expressions guide) and stores
`[x, y, z, a, b]` in both cases.
The in-memory backend stored the wrong list, and since transactions
refresh instances with the same evaluator, instances updated in a
transaction on AWS could differ from the stored item too.
SET actions are now assigned in path order, which sets the elements of
each list in order of their index. A path through an element past the
end (`l[3].k` on a three-element list) is therefore refused whatever
the order of the actions, as it is when it is the only action.
Fixes #74
Co-authored-by: Carl Oscar Aaro <[email protected]>
Keeps both CHANGELOG.md entries under Fixed: the one for optional fields with a codec of their own (#105), then this branch's for list elements set past the end. Co-authored-by: Carl Oscar Aaro <[email protected]>
Keeps both CHANGELOG.md entries under Fixed: the one for PartiQL transactions that name an item twice (#104), then this branch's for list elements set past the end. Co-authored-by: Carl Oscar Aaro <[email protected]>
kalaspuff
deleted the
fctl/53-https-github-com-kalaspuff-dynamoxy-issu
branch
October 30, 2026 23:50
fctl-sh Bot
added a commit
that referenced
this pull request
Oct 30, 2026
…com-kalaspuff-dynamoxy-issu Brings in #103 (list elements set past the end append in order of their index). CHANGELOG.md conflicted where both added an entry at the end of [Unreleased] Fixed: both entries are kept, #103's first. Co-authored-by: Carl Oscar Aaro <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The update evaluator assigned
SETactions in the order of the expression, and an index at or past the end of a list appends. SoSET l[4] = :b, l[3] = :aon[x, y, z]appendedb, then overwrote it witha, and stored[x, y, z, a];SET l[9] = :b, l[5] = :astoredbbeforea. DynamoDB sets the elements of a list in order of their index ("If you add multiple elements in a single SET operation, the elements are sorted in order by element number", the update expressions guide) and stores[x, y, z, a, b]in both cases. The in-memory backend stored the wrong list, and since transactions refresh instances with the same evaluator (_core._apply_update), an instance updated in a transaction on AWS could differ from the stored item too.SETactions are now assigned in path order, which sets the elements of each list in order of their index; their values are still evaluated against the item before the update. That coversUpdateItem, transactions, PartiQL updates and the refresh of instances.Verified with an evaluator test of the issue's cases, a mix of replaced and appended elements, and lists inside maps and lists, and with a transaction test whose refreshed instance lost
bon both backends before the fix. dynoxide-rs's tests captured against DynamoDB (eu-west-2) show the same orders. MiniStack applies the actions in their order (it stores[x, y, z, a], throughUpdateItemandTransactWriteItemsalike), so the transaction test compares the stored item on the in-memory backend only.Fixes #74
Checklist
make checkpasses locally (lint, types, clippy, consistency, Rust and Python tests)Worth confirming
SET l[4] = :m, l[3].k = :aon a three-element list) is now refused whatever the order of the actions. DynamoDB refuses such a path when it is the only action (also captured by dynoxide-rs), and the index order putsl[3]beforel[4], but this combination was not captured; before, the in-memory backend wrote into the appended map when the append came first.ADDon list elements past the end (ADD l[7] :one, l[5] :two) still applies in the order of the actions, since DynamoDB documents the index order only forSET.fctl session
Note
Low risk. It changes only the order in which SET actions are assigned in the update evaluator, which matters only when several elements are set past the end of the same list, and it adds tests.
What it does. The update evaluator now assigns SET actions in path order, so elements set past the end of a list are appended in order of their index, as DynamoDB does, instead of in the order of the actions. This fixes the in-memory backend and the local refresh of instances after a transaction, which could store or show a list with an element lost. Values are still evaluated against the item before the update. The newer commits only merge main into the branch and do not touch the change.
Stricter paths. A path through an element past the end of a list (
SET l[4] = :m, l[3].k = :a) is now refused whatever the order of the actions; before, the in-memory backend accepted it when the append came first.fctl review's first look at
121f91d· 3 files, +61 −3 · Review agent settings