Files
floci/src/main/java/io/github
e313ab5b1d fix(dynamodb): honor customer-supplied KMS key for table SSE (#1923)
* fix(dynamodb): honor customer-supplied KMS key for table SSE

CreateTable discarded SSESpecification.KMSMasterKeyId and always stored
the default AWS-managed key ARN, so CreateTable/DescribeTable responses
never reflected a customer-managed key. It also hardcoded SSEType to
KMS, ignoring AES256. UpdateTable had no SSESpecification handling at
all, so a table's encryption could not be enabled, rotated to a new
key, or disabled after creation.

* fix(dynamodb): persist post-create/update SSE state and validate SSEType

Address PR review feedback: CreateTable/UpdateTable mutated the table's
SSE fields after the service layer's own persistence call, so a
persistent/WAL storage backend would silently drop the encryption
settings (along with other post-create/update fields) on reload. Both
handlers now re-persist the fully mutated table before responding.

SSEType was also accepted verbatim with no enum check, letting an
invalid value be stored and echoed back in SSEDescription. Both
handlers now validate it against {KMS, AES256}.

Adds a reload test proving SSE settings survive a fresh
PersistentStorage instance reading the same file, an AES256 coverage
test, and validation-failure tests for both CreateTable and
UpdateTable.

* fix(dynamodb): validate SSEType before mutating, not after

Closes the remaining review items on this PR:

- Resolved the merge conflict with #1811 (global table v2 replicas) in
  handleUpdateTable. Also found and fixed a duplicate: main had
  independently added its own persistTable(...) flush for the same
  stream-persistence reason this PR added one for SSE, so the two
  collapse into one call.

- Moved SSEType validation ahead of createTable/updateTable in both
  handlers, mirroring the existing validateReplicaUpdates-before-
  updateTable pattern already used in handleUpdateTable. Previously an
  invalid SSEType threw only after the table (and possibly its stream)
  were already created/mutated, leaving real side effects behind a
  ValidationException -- real DynamoDB rejects the whole request first.

- The merge resolution deliberately does NOT follow the literal
  "replica block first" suggestion from review: applyReplicaUpdates
  re-fetches the table from storage for its own persist, and a
  persistent backend does not hold the live object (confirmed by
  reading both applyReplicaUpdates itself and the comment already on
  main's persistTable call). Running it before the stream/SSE
  mutations are flushed would silently drop them, not just SSE's.
  Kept main's original persistTable-then-applyReplicaUpdates ordering
  instead, with the SSE block slotted in before the flush, matching
  the same stream-then-SSE-then-persist shape CreateTable already uses.

- Added DescribeTable assertions to both existing invalid-SSEType
  tests confirming no side effects survive the failed request (no
  table for CreateTable, no SSEDescription change for UpdateTable) --
  meaningful now that validation actually runs first.

AES256 test coverage (createTableWithAes256SseOmitsKmsMasterKeyArn)
was already present as of the second commit on this branch; no
further gap there.

---------

Co-authored-by: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
Co-authored-by: Priamo <pgermosen@gmail.com>
2026-09-07 23:46:15 -04:00
..