Skip to content

fix(indexes): reads refuse filters and projections of attributes an index does not hold - #148

Merged
kalaspuff merged 23 commits into
mainfrom
parity-stack/2-index-reads
Oct 31, 2026
Merged

kalaspuff merged 23 commits into
mainfrom
parity-stack/2-index-reads

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

Summary

Reads of an index that name attributes it does not hold passed in tests and failed against DynamoDB. Measured in eu-north-1 (docs/parity, rounds 1 and 2), DynamoDB refuses a Query filter on such attributes for local indexes too, whatever the query returns (ALL_ATTRIBUTES, COUNT, a projection it fetches from the table), naming each place the filter reads one by its top-level name in order ([_type, _type], [secret, m]), and refuses a projection of a global index naming them in queries and scans. A scan's filter sees what the scan returns: the index entries, where such attributes never match, or the items it fetches from the table. The in-memory backend now does the same with DynamoDB's messages.

Model queries raise ValueError before any request for a filter of a KEYS_ONLY/INCLUDE local index on an attribute it does not hold (they sent it with Select=ALL_ATTRIBUTES), as they did for global ones; scans of such a local index read the items and keep their filters, unless they project only what the index holds. Model reads raise ValueError for .project(...) of a global index naming one, unless the query adds .hydrate() (before or after), which now reads the index for the keys only and takes the attributes from the full items. ADR 0021 amends ADR 0012; guides, AGENT_GUIDE, the skill and the changelog follow.

Verified with make check (Rust and Python tests, the integration tests on the memory backend and MiniStack, lint, types, consistency) and a new memory backend test with DynamoDB's messages; the refusals are asserted on the memory backend only, since MiniStack accepts them.

Worth confirming

  • Decision: model reads keep filtering partial indexes on attribute_not_exists(_type) OR _type = :entity. dynamoxy creates such indexes with _type, so that works; queries of an index without it (created by other tools or by dynamoxy 0.2) now fail with DynamoDB's ValidationError and the index has to be created again. Dropping the filter would make them work but let every partial index query return, count and limit other entities' entries.

Fixes #106

fctl session


Note

Medium risk. It changes what model reads of KEYS_ONLY and INCLUDE indexes send: filters and projections that used to be sent now raise ValueError before any request, and the in-memory backend answers index reads differently.

What it does. Makes the in-memory backend refuse what DynamoDB refuses when a query or scan reads a KEYS_ONLY or INCLUDE index: query filters on attributes the index does not hold, and projections of a global index that name them. Model reads now raise ValueError for those cases before any request, .hydrate() reads such an index for its keys only and takes the attributes from the full items, and a scan of a local index filters the fetched items only when the request returns them from the table. Adds ADR 0021, tests, guide updates and a changelog entry; since the last review it only merges main in, with no change to the code of the fix.

Behavior change. Filters on attributes an index does not hold, and .project(...) of such a global index without .hydrate(), now raise ValueError instead of being sent; queries of an index that lacks the type attribute fail in DynamoDB and need the index created again.

fctl review's first look at 0e31db3 · 15 files, +343 −30 · Review agent settings

fctl-sh Bot and others added 7 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]>
@fctl-review

This comment has been minimized.

Comment thread python/dynamoxy/query.py Resolved
fctl-sh Bot and others added 4 commits October 31, 2026 14:31
…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]>
@fctl-review

This comment has been minimized.

Comment thread python/dynamoxy/query.py Resolved
@fctl-sh

fctl-sh Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Stack of 8 pull requests, merged in this order with "Squash and merge":

  1. docs(parity): keep DynamoDB's measured answers and the probes that ask them #147 docs(parity): keep DynamoDB's measured answers and the probes that ask them (merged)
  2. fix(indexes): reads refuse filters and projections of attributes an index does not hold #148 fix(indexes): reads refuse filters and projections of attributes an index does not hold ← this pull request
  3. fix(tables): the in-memory backend refuses table changes DynamoDB refuses #149 fix(tables): the in-memory backend refuses table changes DynamoDB refuses
  4. fix(versions)!: version() fields hold a random token, so a stale instance never matches again #150 fix(versions)!: version() fields hold a random token, so a stale instance never matches again
  5. fix(expressions): the in-memory backend refuses placeholders, names and operands DynamoDB refuses #151 fix(expressions): the in-memory backend refuses placeholders, names and operands DynamoDB refuses
  6. fix(limits): local index entries count toward the 400 KB of an item, and transactions keep to 4 MB #152 fix(limits): local index entries count toward the 400 KB of an item, and transactions keep to 4 MB
  7. fix(errors): LocalStack's DuplicateItem code raises DuplicateItemError, and the e2e tests pass on LocalStack #153 fix(errors): LocalStack's DuplicateItem code raises DuplicateItemError, and the e2e tests pass on LocalStack
  8. test: probe dynamoxy itself on DynamoDB, MiniStack, LocalStack and the in-memory backend #154 test: probe dynamoxy itself on DynamoDB, MiniStack, LocalStack and the in-memory backend

@fctl-review

This comment has been minimized.

Comment thread python/dynamoxy/query.py Resolved
…ilters that would never match

Co-authored-by: Carl Oscar Aaro <[email protected]>
@fctl-review

This comment has been minimized.

Comment thread python/dynamoxy/query.py Resolved
…its filter sees the entries

Co-authored-by: Carl Oscar Aaro <[email protected]>
@kalaspuff
kalaspuff added this pull request to stack #155 October 31, 2026 18:18
Base automatically changed from fctl/154-what-do-you-need-me-to-test-to-be-able-t to main October 31, 2026 18:21
@kalaspuff
kalaspuff merged commit 331e9eb into main Oct 31, 2026
22 checks passed
@kalaspuff
kalaspuff deleted the parity-stack/2-index-reads branch October 31, 2026 18:27
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.

Filters and projections of attributes an index does not project: DynamoDB rejects some that dynamoxy accepts

1 participant