Skip to content

fix(memory): PartiQL transactions that name an item twice are refused - #104

Merged
kalaspuff merged 2 commits into
mainfrom
fctl/54-https-github-com-kalaspuff-dynamoxy-issu
Oct 30, 2026
Merged

kalaspuff merged 2 commits into
mainfrom
fctl/54-https-github-com-kalaspuff-dynamoxy-issu

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What and why

The in-memory DynamoDB's ExecuteTransaction never checked whether two statements named the same item. It prepares every statement against the items as they were before the transaction and then applies them all, so such a transaction lost writes silently: UPDATE t SET a = 1 WHERE pk = 'x' AND sk = 1 plus UPDATE t SET b = 2 WHERE pk = 'x' AND sk = 1 succeeded and left a = 0, b = 2, and an INSERT plus a DELETE of one item left it stored. Read transactions that named an item twice ran too. DynamoDB refuses all of these before running any statement, so code tested on the in-memory backend failed in production.

The memory backend now refuses them with the ValidationException that its TransactWriteItems and TransactGetItems already give, "Transaction request cannot include multiple operations on one item" (dynamoxy.ValidationError). Statements are compared by the key they read or write, whatever the order of the key conditions, the form of a number (1 and 1.0) or whether the key comes from parameters. A statement whose table does not exist or that names no full key takes no part and fails on its own, as before. The error, and that such statements are left out, follow the tests of dynoxide-rs, which were captured against DynamoDB.

Verified with a memory backend test in Rust, which failed before the fix: two updates of an item, an insert and a delete, key conditions in another order with a number written 1.0 and parameters, and two selects; the refused transactions write nothing and leave their idempotency token free. A Python integration test checks the ValidationError and that the item is unchanged. MiniStack runs such statements one after another (checked by hand), so that test skips it, like the ORDER BY test. The rest of the Rust and Python suites pass too.

BatchExecuteStatement has the same rule on DynamoDB ("Provided list of item keys contains duplicates"). The memory backend still runs both statements of such a batch; that and the other PartiQL gaps stay with #97.

Fixes #75.

Checklist

  • Tests cover the change (memory backend in Rust and Python; MiniStack accepts these transactions, so the Python test skips it)
  • Docs updated (low-level access guide, changelog)
  • make check passes locally (lint, types, clippy, consistency, Rust and Python tests)
  • Breaking change? No: transactions that DynamoDB refuses now fail on the in-memory backend too

fctl session


Note

Low risk. It only changes the in-memory test backend, so that PartiQL transactions DynamoDB refuses now fail there too; the AWS backend and production paths are untouched.

What it does. The in-memory ExecuteTransaction now refuses a PartiQL transaction in which two statements address the same item, with the same ValidationException that TransactWriteItems and TransactGetItems already return. Before, each statement was prepared against the pre-transaction items, so writes were silently lost. Statements are compared by table and key, regardless of key condition order, number form or parameters. A Rust memory-backend test, a Python integration test, a changelog entry and a docs line come with it.

fctl review's first look at e55c060 · 5 files, +110 −1 · Review agent settings

The in-memory ExecuteTransaction prepared every statement against the
items as they were before the transaction and then applied them all,
so two statements on one item lost a write: of `SET a = 1` and
`SET b = 2` only the second took effect, and an INSERT plus a DELETE
of one item left it stored. Read transactions that named an item twice
ran too.

DynamoDB refuses such transactions before running any statement, with
the ValidationException that TransactWriteItems and TransactGetItems
give ("Transaction request cannot include multiple operations on one
item"). The memory backend now does the same, comparing the key each
statement reads or writes, whatever the order of the key conditions,
the form of a number or whether the key comes from parameters. A
statement without a table or a full key takes no part and fails on its
own, as before.

Fixes #75.

Co-authored-by: Carl Oscar Aaro <[email protected]>
Brings in #105 (optional fields with a codec of their own). Both sides
appended an entry to the Fixed section of CHANGELOG.md; both are kept,
#105's first since it landed first.

Co-authored-by: Carl Oscar Aaro <[email protected]>
@kalaspuff
kalaspuff merged commit 86f2c0d into main Oct 30, 2026
22 checks passed
@kalaspuff
kalaspuff deleted the fctl/54-https-github-com-kalaspuff-dynamoxy-issu branch October 30, 2026 23:42
fctl-sh Bot added a commit that referenced this pull request Oct 30, 2026
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]>
fctl-sh Bot added a commit that referenced this pull request Oct 30, 2026
…com-kalaspuff-dynamoxy-issu

Brings in #104 (PartiQL transactions that name an item twice are
refused). CHANGELOG.md conflicted where both added an entry at the end
of [Unreleased] Fixed: both entries are kept, #104's first.

Co-authored-by: Carl Oscar Aaro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In-memory PartiQL: ExecuteTransaction accepts several statements on one item and loses writes

1 participant