Skip to content

fix(client): batch and transaction writes return the item collection metrics they ask for - #118

Merged
kalaspuff merged 1 commit into
issues-stack/3-fast-set-conversionfrom
issues-stack/4-batch-collection-metrics
Oct 31, 2026
Merged

kalaspuff merged 1 commit into
issues-stack/3-fast-set-conversionfrom
issues-stack/4-batch-collection-metrics

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

What and why

batch_write_item and transact_write_items accept return_item_collection_metrics=True, the core asks DynamoDB for the metrics and parses them, and the in-memory DynamoDB computes them, but the binding built both output dicts without them, and the stub's TypedDicts left the key out. On a table with a local index, put_item returned its metrics, while batch_write_item returned only unprocessed_items and consumed_capacity, and transact_write_items only consumed_capacity. client.call(...) is the documented way to reach these parameters.

Both outputs now carry item_collection_metrics: a dict of lists of metrics per table, empty when not asked for, typed in _core.pyi. The low-level access guide shows the parameter.

Verified with an integration test that fails without the fix: put_item returns the metrics on the in-memory backend and MiniStack, the outputs have the key on both, and on the in-memory backend a batch with a put and a delete and a transaction return one entry per write. MiniStack (1.5.33) returns metrics only for single-item writes, so those assertions run on the in-memory backend only. make check passes.

Fixes #95

Checklist

  • Tests cover the change (in-memory backend and MiniStack)
  • Docs updated (low-level access guide, changelog; stub)
  • make check passes locally (lint, types, clippy, consistency, tests)
  • Breaking change? No

fctl session


Note

Low risk. It only adds a key to the dicts the native binding returns for two low-level operations, with no change to requests, retries or stored data.

What it does. batch_write_item and transact_write_items already asked DynamoDB for item collection metrics and the core parsed them, but the PyO3 binding dropped them when building the output dicts. The binding now returns an item_collection_metrics dict of lists per table (empty when not requested), the stub types it, and the low-level access guide and changelog describe it. An integration test checks the key on both backends and the per-write entries on the in-memory backend.

fctl review's first look at 1103e56 · 6 files, +94 −4 · Review agent settings

…metrics they ask for

batch_write_item and transact_write_items accept
return_item_collection_metrics=True, the core asks for and parses the
metrics, and the in-memory DynamoDB computes them, but the binding built
the output dicts without them and the stub's TypedDicts left the key
out. Both outputs now carry item_collection_metrics, a list of metrics
per table, as put_item, update_item and delete_item carry theirs.

Fixes #95

Co-authored-by: Carl Oscar Aaro <[email protected]>
@kalaspuff
kalaspuff added this pull request to stack #124 October 31, 2026 01:30
@kalaspuff
kalaspuff merged commit 2e8fa64 into main Oct 31, 2026
22 checks passed
@kalaspuff
kalaspuff deleted the issues-stack/4-batch-collection-metrics branch October 31, 2026 01:34
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.

Binding: item collection metrics of BatchWriteItem and TransactWriteItems are dropped

1 participant