fix(payment-methods): delete correct QR S3 keys, clean up replaced QR objects, return presigned URL - #174
Merged
Merged
Conversation
dmeiser
force-pushed
the
fm/KW-QR-S3-LIFECYCLE
branch
from
August 24, 2026 09:49
bcb1e74 to
6579a5b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Fix three data-integrity issues in kernelworx payment-method QR code S3 handling (one focused PR, no broad refactors): Issue #137 (High): payment-method deletion deletes the wrong QR S3 key - _delete_qr_if_exists in src/utils/payment_methods.py reconstructs a slug-based key via delete_qr_from_s3(account_id, name) while uploads use UUID-based keys, so the S3 object is never deleted; fix by deleting the stored key with delete_qr_by_key(method_to_delete['qrCodeUrl']). Issue #138 (Medium): re-uploading a QR code orphans the previous S3 object - request_qr_upload generates a fresh UUID key each time; delete the previous qrCodeUrl object when confirming a new upload. Issue #139 (Medium): confirm_qr_upload returns a raw S3 key instead of the presigned GET URL its docstring promises; return a freshly minted presigned GET URL. Data contract decided: DynamoDB stores the raw S3 key, clients always receive presigned GET URLs (AppSync field resolver passes already-presigned values through). Existing tests must pass; focused regression tests were added that fail before the fix and pass after. Commit references Closes #137, closes #138, closes #139.
What Changed
qrCodeUrlinstead of reconstructing a slug-derived key that never matched the uploaded object.qrCodeUrlis replaced, preventing orphaned objects on re-upload.confirm_qr_uploadto return a freshly generated presigned GET URL instead of the raw S3 key, matching its documented contract.Risk Assessment
✅ Low: The change is a focused, well-bounded fix that correctly addresses all three stated issues: payment-method deletion now deletes the stored UUID-based S3 key, confirm_qr_upload cleans up the previous QR object on re-upload, and it returns a freshly minted presigned GET URL while keeping the raw key in DynamoDB. Regression tests cover the new behavior and edge cases (same-key confirmation), and existing tests were updated appropriately. No material bugs or breaking changes were found.
Testing
Ran the focused payment-method QR S3 unit tests plus a moto-backed end-to-end demo that exercises all three fixes. The demo passes on the target commit and fails on the base commit, showing the regression tests detect the original issues. All 136 payment-methods unit tests pass.
Evidence: End-to-end QR S3 regression demo script
Evidence: Demo output on target commit (passes)
Evidence: Demo output on base commit (fails on #137)
Evidence: Focused pytest output
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
uv run pytest tests/unit/test_payment_methods.py tests/unit/test_payment_methods_handlers.py -v --no-cov(136 tests passed)uv run python /tmp/no-mistakes-evidence/01M0RJ2E7BSP28GFDYE5H2D6HE/qr_s3_regression_demo.pyon target commit (bcb1e741)git checkout 776cb419then re-ran the same demo script on the base commit to verify it fails before the fixgit checkout bcb1e741restored the target commit after the base demo✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.