Skip to content

fix(errors): LocalStack's DuplicateItem code raises DuplicateItemError, and the e2e tests pass on LocalStack - #153

Merged
kalaspuff merged 101 commits into
mainfrom
parity-stack/7-localstack
Oct 31, 2026
Merged

kalaspuff merged 101 commits into
mainfrom
parity-stack/7-localstack

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

Summary

dynamoxy's end-to-end tests now pass against LocalStack as well as MiniStack: 211 passed and 6 skipped, with the Rust parity scenarios passing too. LocalStack runs DynamoDB Local, AWS's own emulator, and docs/parity shows how to run it without Docker. A new target test fixture ("memory", "ministack" or "localstack") tells the emulators apart by MiniStack's health path, which LocalStack does not serve (MiniStack does answer LocalStack's). Tests use it to skip what LocalStack's free edition lacks: backups, point-in-time restores, item collection metrics and the LastEvaluatedKey of PartiQL pages. The test of steps without waiting creates its second table under a new name, since LocalStack keeps the Time to Live of a table deleted and created again.

One library fix: DynamoDB Local sends the code DuplicateItem for a PartiQL INSERT of an item that exists, where DynamoDB sends DuplicateItemException, so dynamoxy raised a plain ServiceError there; both codes now raise DuplicateItemError. Round 3 confirmed against DynamoDB what the tests expect where LocalStack differs: a duplicate INSERT in a transaction has the reason DuplicateItem, PartiQL pages carry LastEvaluatedKey, and a table created again has no Time to Live.

Verified with make check (memory and MiniStack) and the e2e tests and Rust parity scenarios against LocalStack 2026.3.0.

Worth confirming

  • Decision: LocalStack is not added to CI. It needs Python 3.13, dependencies pinned to its release date, and a JDK and DynamoDB Local downloaded at start. Running it locally is documented in docs/parity.

Refs #87, #93, #97, #106

fctl session


Note

Low risk. The only library change is one more error code accepted in ErrorKind::from_code; everything else is test fixtures, LocalStack skips, docs and a changelog line.

What it does. A PartiQL INSERT of an item that exists now raises DuplicateItemError on LocalStack too: its DynamoDB Local sends the code DuplicateItem where DynamoDB sends DuplicateItemException, and both codes map to the same error kind. The end-to-end tests also pass on LocalStack through a session-scoped emulator_kind fixture and a per-test target fixture (memory, ministack or localstack), which skip what LocalStack's free edition lacks (backups, point-in-time restores, item collection metrics, PartiQL LastEvaluatedKey). One test creates its second table under a new name because LocalStack keeps the Time to Live of a deleted table, and docs/parity records how LocalStack differs from DynamoDB. LocalStack is documented but not added to CI.

fctl review's first look at 56fe1fa · 7 files, +74 −16 · Review agent settings

fctl-sh Bot and others added 29 commits October 31, 2026 13:38
Creates throwaway tables, asks the questions #87, #93, #97 and #106 leave
open, logs every answer (with account ids masked) and deletes the tables.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…ndex does not hold

DynamoDB refuses a query filter on attributes an index does not hold,
for local indexes too and whatever the query returns, and a projection
of a global index naming them (measured in eu-north-1, docs/parity).
The in-memory backend now does the same with DynamoDB's messages, its
scan filters see the index entries, and model reads raise ValueError
before any request (ADR 0021).

Co-authored-by: Carl Oscar Aaro <[email protected]>
…be round

AWS CLI v1 base64-encodes the B values of JSON input itself, so the
base64 text written for v2 became 400 KB items; the generators now write
what the version in use sends as the intended bytes. Round 3 asks where
LocalStack and the tests disagree.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…f fetched items are an assumption

Co-authored-by: Carl Oscar Aaro <[email protected]>
…uses

Measured in eu-north-1 (docs/parity): DynamoDB refuses a switch to
provisioned billing without capacity for each global index, an index
without capacity on a provisioned table, index capacity on an on-demand
table, changes to a table it is still creating, and a second index while
one is being created. The in-memory backend now does the same, drops
index capacity on a switch back to on-demand, and keeps new tables and
indexes CREATING until a DescribeTable sees them. table.add_index()
gives an index of a provisioned table the table's capacity.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…n during a backfill follows DynamoDB's message

Co-authored-by: Carl Oscar Aaro <[email protected]>
…be, so a lone describe does not end it

add_index() without billing= describes the table, which ended CREATING
in the in-memory backend and hid the missing wait DynamoDB refuses. A
table or index being created now reads CREATING in the first
DescribeTable and ACTIVE from the next on, as a poller sees it; the
client's waiter polls the in-memory backend without sleeping.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…ance never matches again

A counter started again at 1 on a put() of an instance that was not
loaded and on delete-and-create, so an instance loaded before passed its
version check again and overwrote both writes (#84). Versions are now
random tokens (Attr[str]), set on every write; transactions with an
idempotency token derive theirs from it, so a retry is the same request
(ADR 0022).

BREAKING CHANGE: version() fields must be declared Attr[str]
(Annotated[str | None, Version()] in pydantic models); stored numeric
versions are not read.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…nd operands DynamoDB refuses

Measured in eu-north-1 (docs/parity): placeholders over 255 bytes or
with invalid characters, attribute names of 64 KB or more, and
attribute_type(a, b) with a path are refused, and a read-only
ExecuteTransaction of a missing table is canceled with reason
ResourceNotFound. Single-item writes put their expression errors and
refused attribute names in DynamoDB's request-validation envelope, as
dynoxide-rs captured.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…and transactions keep to 4 MB

Measured in eu-north-1 (docs/parity): an item and its entries in local
indexes share the 400 KB limit (a transaction cancels with it as the
reason), a TransactGetItems may return at most 4 MB, and an oversized
TransactWriteItems has its own message. The in-memory backend now
refuses them like DynamoDB.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…r, and the e2e tests pass on LocalStack

DynamoDB Local (inside LocalStack) sends DuplicateItem for a PartiQL
INSERT of an item that exists, where DynamoDB sends
DuplicateItemException. The tests' target fixture tells MiniStack and
LocalStack apart and skips what LocalStack's free edition lacks.

Co-authored-by: Carl Oscar Aaro <[email protected]>
fctl-sh Bot and others added 7 commits October 31, 2026 17:01
…ndition form tested, and the payload measurements in a table

Co-authored-by: Carl Oscar Aaro <[email protected]>
…ad as DynamoDB counts it

Measured one form at a time through the probe's third run on AWS: a
path in a condition counts as where it is read, and each form adds a
constant on top of its operands. All eighteen measured conditions and
every payload size of the runs now match exactly.

Co-authored-by: Carl Oscar Aaro <[email protected]>
@kalaspuff
kalaspuff added this pull request to stack #155 October 31, 2026 18:18
fctl-sh Bot added 18 commits October 31, 2026 18:21
…stack/2-index-reads

# Conflicts:
#	CHANGELOG.md
Base automatically changed from parity-stack/6-size-limits to main October 31, 2026 18:33
@kalaspuff
kalaspuff merged commit 6f7b82e into main Oct 31, 2026
20 checks passed
@kalaspuff
kalaspuff deleted the parity-stack/7-localstack branch October 31, 2026 18:36
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.

1 participant