Skip to content

fix(dynamodb): show items as plain JSON and stop double-encoding keys - #169

Merged
DaviReisVieira merged 1 commit into
DaviReisVieira:mainfrom
vaibhavkr993630-droid:fix/dynamodb-item-display
Sep 21, 2026
Merged

DaviReisVieira merged 1 commit into
DaviReisVieira:mainfrom
vaibhavkr993630-droid:fix/dynamodb-item-display

Conversation

@vaibhavkr993630-droid

Copy link
Copy Markdown
Contributor

Fixes #163

Problem

In the DynamoDB view, items were displayed as raw DynamoDB-typed JSON ({"S": "Hello"}) in the items table, and the edit modal was wrong in both modes.

Cause

/api/dynamodb/tables/{name}/items (and /query) return DynamoDB-typed attributes, and the backend tests rely on that. DynamoDBBrowser treated them as plain values:

  • the items table rendered JSON.stringify of the typed attribute
  • the edit modal's "Plain JSON" mode showed typed data, and switching to "DynamoDB JSON" wrapped it a second time
  • Delete / Delete selected wrapped the already-typed key again before sending it

Fix (frontend only, DynamoDBBrowser.tsx)

  • Convert items to plain values for the items table
  • Edit opens in Plain JSON, like the AWS console. Switching to DynamoDB JSON on an untouched item shows the original typed item, so sets (SS) keep their exact types
  • Delete sends the typed key as returned by the API
  • Reuse dynamoItemToPlainMap instead of a duplicate local decoder

Testing

  • Updated the browser test mocks to the real typed response shape (the old mocks used plain values, which hid the bug) and added tests for plain display, format switching and saving without double-encoding
  • tsc -b, eslint and the DynamoDB tests pass
  • Checked by hand against MiniStack using the steps from the issue: the table shows Hello / 42 / ["a","b"], Edit shows plain JSON, DynamoDB JSON shows the exact typed form, and Delete removes the row

Note

Saving in Plain JSON mode still writes string sets back as lists (plain JSON has no set type). Use DynamoDB JSON mode to keep a set.

The items API returns DynamoDB-typed attributes ({"S": "Hello"}), but the
browser treated them as plain values. The items table showed raw typed JSON,
the edit modal's "Plain JSON" mode showed typed data (and switching to
"DynamoDB JSON" wrapped it a second time), and delete wrapped the key again,
sending a malformed key.

- Convert items to plain values for the items table
- Open the edit modal in Plain JSON; switching to DynamoDB JSON on an
  untouched item shows the original typed item, so sets keep their types
- Send the typed key as returned by the API when deleting
- Reuse dynamoItemToPlainMap instead of a duplicate local decoder
- Use typed items in the browser test mocks and add tests for plain display,
  format switching and saving without double-encoding

Fixes DaviReisVieira#163
@DaviReisVieira
DaviReisVieira merged commit eaa044e into DaviReisVieira:main Sep 21, 2026
2 checks passed
@DaviReisVieira

Copy link
Copy Markdown
Owner

Merged!! Thanks a lot for this. Reproducing first and posting the plan on the issue before opening the PR made the review easy, and swapping the test mocks to the real typed shape was the right call, the old ones were hiding the bug.

Two follow-ups, neither on you:

If #172 or #170 look fun to you, go for it!

DaviReisVieira added a commit that referenced this pull request Sep 21, 2026
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.

DynamoDB Item display not serialising correctly

2 participants