You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bb-kv-store: an expired item is gone locally after get(), but still blocks put({ ifNotExists }) and shows up in scan({ includeExpired }) on AWS #1275
I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Which package(s) are affected?
Building Block: kv-store
Describe the bug
DynamoDB's TTL deletes expired items in the background, typically within a few days; until then they still exist for reads, conditional writes and scans. The block hides them from get() and scan() in both environments, but the local mock also deletes an expired item as soon as get() sees it, and the AWS path doesn't treat expired items as absent in its conditions. After put(key, v, { expiresAt: <past> }) and a get(key) that returns null:
Next call
Local
Deployed
put(key, 'fresh', { ifNotExists: true })
ok
ConditionalCheckFailedException (409)
delete(key, { ifExists: true })
ConditionalCheckFailedException (409)
ok
scan({ includeExpired: true })
item not yielded
item yielded
So the common "create if absent" pattern (for example a lock or an idempotency key with a TTL) works locally and fails on AWS for as long as the expired item lingers, even though get() reports the key as absent in both environments.
Expected behavior
get(), conditional writes and scan() agree about expired items in both environments. Probably:
AWS: ifNotExists uses attribute_not_exists(pk) OR <ttl> < :now and ifExists uses attribute_exists(pk) AND <ttl> >= :now (or the absence of the TTL attribute), so an expired item counts as absent, matching get().
Mock: get() filters expired items without deleting them, so scan({ includeExpired: true }) still yields them until the reaper runs, as on AWS.
Reproduction steps
conststore=newKVStore<string>(scope,'locks',{});constpast=newDate(Date.now()-60_000);awaitstore.put('job-42','old',{expiresAt: past});awaitstore.get('job-42');// null in bothawaitstore.put('job-42','fresh',{ifNotExists: true});// ok locally, ConditionalCheckFailedException deployed
Likely location: get() in packages/bb-kv-store/src/index.mock.ts (lines 141–150 delete the entry when it is expired); the conditions in put() / delete() in packages/bb-kv-store/src/index.aws.ts (around lines 114–115 and 197–198).
Activity
sharonyajain commentedon Nov 18, 2026
Thanks for the detailed report. Closing this one.
Local store: fixed on
mainby #1453. The mock no longer deletes an expired item whenget()reads it.