feat(dynamodb): item CRUD, batch write, and JSON editor UI (#69)#107
Conversation
DaviReisVieira
left a comment
There was a problem hiding this comment.
Hey @saurabhkhadsangTV, thanks for the PR! Really nice work here — the DynamoDB CRUD implementation is solid and covers all the acceptance criteria from #69. The ReadOnlyMiddleware fix alone is an important catch. 👏
I went through the code, ran the full test suite (backend + frontend + typecheck + lint), and everything looks good overall. Just two things I'd like us to fix before merging:
1. Cache not invalidated on partial batch success
In backend/routes/dynamodb.py (lines 353-363), when batch_write_item returns UnprocessedItems, we skip cache invalidation — but some items were written, so the item count goes stale until TTL expires.
# Currently:
uproc = resp.get("UnprocessedItems", {})
if uproc:
return { ... } # <-- returns early, skips invalidation
_invalidate_table_item_count(name, endpoint_url) # never reached on partial successEasy fix — just move _invalidate_table_item_count before the if uproc check.
2. Frontend silently swallows partial batch failures
The frontend calls batchWriteDynamoDBItems and only checks res.ok, but doesn't inspect the unprocessed field in the response. If some items fail in a batch, the user gets a green success toast with no hint that anything went wrong. Could we add a warning toast like "Imported X items, but Y were not processed — retry needed" when unprocessed is non-empty?
Everything else looks great — the Pydantic schemas, the marshal library with round-trip tests, the plain/DynamoDB JSON toggle, the useHealth-gated write actions. Nice attention to detail on the whole thing. 🙌
…user on unprocessed items
7cd6cb2 to
1839b88
Compare
…to feat/#69/dynamodb-item-crud-with-json-editor Resolve ui/dist conflicts by rebuilding the UI bundle; index.html now matches the current Vite output.#
1d28301 to
5d28980
Compare
Summary
Closes DaviReisVieira/stackport#69.
Implements create / update / delete for DynamoDB items, batch import and bulk delete, a JSON-based editor with plain vs DynamoDB attribute-value modes, and tightens the read-only middleware so item write
POSTroutes are not mistaken for the existingPOST .../queryread path.What changed
Backend
POST/PUT/api/dynamodb/tables/{name}/items—put_item(item+item_format:dynamodb|plain)DELETE/api/dynamodb/tables/{name}/items—delete_item(JSONkey+item_format)POST/api/dynamodb/tables/{name}/items/batch—batch_write_item(≤25 ops, put/delete)boto3.dynamodb.types.TypeSerializer; key attributes validated againstdescribe_tablePOSTonly for paths ending in/query(DynamoDB) and/invoke(Lambda), not for all/api/dynamodb/tables/...prefixesFrontend
Textarea, Plain ↔ DynamoDB toggle (dynamodb-marshalhelpers),JSON.parsevalidation, Sonner toastsuseHealthto hide write actions whenwrites_enabledis falserounded-lg border bg-card …panel; tab panels usedata-[state=inactive]:hiddento avoid flex layout glitchesui/distrebuiltTests
tests/test_dynamodb_routes.py—TestItemWrites(put typed/plain, missing key, delete, batch)tests/test_readonly_middleware.py—POSTto/itemsand/items/batchreturn 403 when writes disabledui—dynamodb-api,dynamodb-marshal, existing suites greenHow to verify
STACKPORT_ALLOW_WRITES=false: write actions hidden / API returns 403 for writes.cd ui && npx tsc -b && npm run build && npx vitest runandpython -m pytest— all pass.Checklist
vitest; backendpytest(incl. new tests)backend/schemas/dynamodb.py(not inline in routes)