Skip to content

fix: unmask delete errors, make values/items membership work, drop debug prints - #2

Merged
thorwhalen merged 1 commit into
masterfrom
fix/delitem-error-masking-membership-views-and-debug-prints
Sep 22, 2026
Merged

thorwhalen merged 1 commit into
masterfrom
fix/delitem-error-masking-membership-views-and-debug-prints

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Three contained defects, all reproduced offline with an in-memory boto3 stand-in
(no AWS, no DynamoDB Local) in the new tests/test_offline.py:

  1. DynamoDbPartitionPersister.__delitem__ did getattr(e, "__name__") inside
    except Exception as e. Exception instances never carry __name__, so every
    failing delete raised AttributeError and destroyed the real error.
    DynamoDbBasePersister.__delitem__ guarded the same line with hasattr and so
    silently never detected a missing key either. Both now share
    is_no_such_key_error, reading the backend error code from
    error.response['Error']['Code'].
  2. ValuesView.__contains__ / ItemsView.__contains__ called
    self._mapping.contains_value(...) / contains_item(...), methods that exist
    neither here nor in dol — so v in store.values() and item in store.items()
    both raised AttributeError. Now implemented against the fast paths that do
    exist (single-scan iter_values, one point read via get).
  3. Removed three debug prints that shipped in the library.

Backward compatible: no public name is removed, renamed or re-signatured. Each
changed path today either raises AttributeError unconditionally or writes to
stdout, so there is no working behaviour to preserve.

Refs #1 — this fixes the footnote defects only; the structural dol-hooks refactor
in that issue stays open, so this PR does not close it.

Branch sat pushed with green CI and no PR for two weeks (thorwhalen/fleet_stuff
cleanup). Verified: master has not moved since the branch was cut (no rebase
needed), and wads ci-local is green on py3.10 and py3.12 (11/11 checks, 11 tests
passed on each).

dynamodol has no dependents in the fleet manifest.

🤖 Generated with Claude Code

…bug prints

Three contained defects, all reproduced offline with an in-memory boto3
stand-in (no AWS, no DynamoDB Local) in the new tests/test_offline.py.

1. `DynamoDbPartitionPersister.__delitem__` did `getattr(e, "__name__")`
   inside `except Exception as e`. Exception *instances* never carry
   `__name__` (it lives on the class), so every failing delete raised
   `AttributeError: 'ClientError' object has no attribute '__name__'`
   and destroyed the real error. `DynamoDbBasePersister.__delitem__`
   guarded the same line with `hasattr` and so silently never detected
   a missing key either.

   Both now share `is_no_such_key_error`, which reads the backend error
   code from `error.response['Error']['Code']` (falling back to the
   exception's class name). The real exception propagates, and the
   intended `NoSuchKeyError` becomes reachable for the first time.

2. The nested `ValuesView.__contains__` / `ItemsView.__contains__`
   called `self._mapping.contains_value(...)` / `contains_item(...)`,
   methods that exist neither here nor in dol — so `v in store.values()`
   and `item in store.items()` both raised `AttributeError`. They are
   now implemented against the fast paths that do exist: values reuse
   the single-scan `iter_values`, items do one point read via `get`.

3. Removed three debug prints that shipped in the library: `x:` in
   `decimal_to_float` (recursive, so once per value *and* per nested
   element on every read), `obj:` in `format_get_item` (every
   `__getitem__`), and `getitem:` in `DynamoDbPartitionReader`.

Backward compatible: no public name is removed, renamed or
re-signatured. Each changed path today either raises `AttributeError`
unconditionally or writes to stdout, so there is no working behaviour
to preserve.

Refs #1 (the footnote defects only; the structural dol-hooks refactor
stays open).

Claude-Session: https://claude.ai/code/session_01L1aQPB34n7PU7jmbztSjBe
@thorwhalen
thorwhalen merged commit 1b5aa09 into master Sep 22, 2026
7 checks passed
@thorwhalen
thorwhalen deleted the fix/delitem-error-masking-membership-views-and-debug-prints branch September 22, 2026 12:49
thorwhalen added a commit that referenced this pull request Sep 22, 2026
… longer KeyErrors (#3)

DynamoDB DeleteItem succeeds silently on an absent key (NoSuchKey is an S3
code), so #2's NoSuchKey mapping never fired: del store[missing] did nothing.
Delete now asks for ReturnValues=ALL_OLD and raises NoSuchKeyError when nothing
was deleted. __getitem__ no longer turns every exception (throttling, auth,
missing table) into NoSuchKeyError, which made .get() and the items view that
#2 added report present keys as absent; only a missing Item or a key the schema
rejects (ValidationException) is a KeyError now.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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