fix: allow alias renewal by re-submitting existing pair#629
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent duplicate alias pair creation by adding an explicit pre-insert check in the alias writer, returning a clear "alias already exists" rejection instead of bubbling up a raw MySQL primary-key error.
Changes:
- Added a duplicate
(address, alias)existence check insrc/writer/alias.tsverify()prior to insert. - Added integration tests validating duplicate alias rejection and non-duplicate acceptance.
- Renamed a unit test
describeblock to correctly referencewriter/alias.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/writer/alias.ts |
Adds DB pre-check to reject duplicate alias pairs with a friendly error. |
test/integration/helpers/alias.test.ts |
Adds integration coverage for the new duplicate check in verify(). |
test/unit/writer/alias.test.ts |
Fixes the unit test suite label from writer/profile to writer/alias. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
a1be547 to
5e4e3e5
Compare
0ebe3fc to
03c0842
Compare
|
Is this to enforce a single user have only 1 alias? If so it wont work, users might be logged on many devices we need multiple working alias for a single user to be possible. |
|
No, it’s to enforce alias is unique, and not associated to multiple adresses |
80d4381 to
3609a15
Compare
a0704ae to
18e7851
Compare
There was a problem hiding this comment.
Pull request overview
Enables alias “renewal” by allowing re-submission of an existing (address, alias) pair without hitting a MySQL duplicate key error, updating the existing row instead.
Changes:
- Update alias writer DB write to use
INSERT ... ON DUPLICATE KEY UPDATEso re-submitting the same pair refreshes stored fields (includingcreated). - Adjust alias self-alias validation to compare against
message.address. - Add/extend integration coverage for renewal behavior and fix a unit test describe label.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/writer/alias.ts |
Writes aliases with ON DUPLICATE KEY UPDATE to support renewals; adjusts self-alias check to use message.address. |
test/integration/helpers/alias.test.ts |
Adds integration tests for renewal / created timestamp bump; changes DB seeding/cleanup strategy. |
test/unit/writer/alias.test.ts |
Renames the top-level describe block to writer/alias. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ee57600 to
0beb198
Compare
Allow the same (address, alias) pair to be submitted again to refresh the expiration. Uses ON DUPLICATE KEY UPDATE to reset created timestamp.
0beb198 to
d7424ee
Compare
Summary
Re-submitting an existing (address, alias) pair was failing with a MySQL duplicate key error. This was problematic for bots and agents that use fixed addresses, as they couldn't renew or extend an alias once created.
Now the same pair can be re-submitted at any time (whether active or expired), which resets the
createdtimestamp and effectively renews the alias. UsesON DUPLICATE KEY UPDATEto handle this at the database level.Changes
INSERTtoINSERT ... ON DUPLICATE KEY UPDATEinaction()to refreshid,ipfs, andcreatedon re-submissionwriter/profile→writer/alias)Test plan
yarn test:unit)yarn test:integration)createdtimestamp