Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

fix: allow alias renewal by re-submitting existing pair#629

Merged
wa0x6e merged 1 commit into
masterfrom
fix/alias-duplicate-check
Apr 1, 2026
Merged

fix: allow alias renewal by re-submitting existing pair#629
wa0x6e merged 1 commit into
masterfrom
fix/alias-duplicate-check

Conversation

@wa0x6e

@wa0x6e wa0x6e commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

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 created timestamp and effectively renews the alias. Uses ON DUPLICATE KEY UPDATE to handle this at the database level.

Changes

  • 🔧 Changed INSERT to INSERT ... ON DUPLICATE KEY UPDATE in action() to refresh id, ipfs, and created on re-submission
  • 🧪 Added integration tests for alias renewal and created timestamp bump
  • 🧹 Fixed describe block name in unit test (writer/profilewriter/alias)

Test plan

  • Verify alias unit tests pass (yarn test:unit)
  • Verify integration tests pass (yarn test:integration)
  • Manually test re-submitting an existing alias pair succeeds and updates the created timestamp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in src/writer/alias.ts verify() prior to insert.
  • Added integration tests validating duplicate alias rejection and non-duplicate acceptance.
  • Renamed a unit test describe block to correctly reference writer/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.

Comment thread src/writer/alias.ts Outdated
Comment thread test/integration/helpers/alias.test.ts Outdated
Comment thread test/integration/helpers/alias.test.ts Outdated
@wa0x6e
wa0x6e force-pushed the fix/alias-duplicate-check branch 4 times, most recently from a1be547 to 5e4e3e5 Compare March 14, 2026 14:22
@wa0x6e wa0x6e self-assigned this Mar 16, 2026
Comment thread test/integration/helpers/alias.test.ts Outdated
@wa0x6e
wa0x6e force-pushed the fix/alias-duplicate-check branch 2 times, most recently from 0ebe3fc to 03c0842 Compare March 17, 2026 13:01
@wa0x6e
wa0x6e requested a review from ChaituVR March 17, 2026 13:05
Comment thread src/writer/alias.ts Outdated
@bonustrack

Copy link
Copy Markdown
Member

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.

@wa0x6e

wa0x6e commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

No, it’s to enforce alias is unique, and not associated to multiple adresses

@wa0x6e
wa0x6e force-pushed the fix/alias-duplicate-check branch from 80d4381 to 3609a15 Compare March 28, 2026 02:32
@wa0x6e wa0x6e changed the title fix: reject alias creation when pair already exists fix: allow alias renewal by re-submitting existing pair Mar 28, 2026
@wa0x6e
wa0x6e force-pushed the fix/alias-duplicate-check branch 4 times, most recently from a0704ae to 18e7851 Compare March 28, 2026 02:41
@wa0x6e
wa0x6e requested review from ChaituVR and Copilot March 28, 2026 02:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 UPDATE so re-submitting the same pair refreshes stored fields (including created).
  • 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.

Comment thread test/integration/helpers/alias.test.ts
@wa0x6e
wa0x6e force-pushed the fix/alias-duplicate-check branch 2 times, most recently from ee57600 to 0beb198 Compare March 28, 2026 03:11
Allow the same (address, alias) pair to be submitted again to refresh
the expiration. Uses ON DUPLICATE KEY UPDATE to reset created timestamp.
@wa0x6e
wa0x6e force-pushed the fix/alias-duplicate-check branch from 0beb198 to d7424ee Compare March 28, 2026 03:12

@ChaituVR ChaituVR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tAck

@wa0x6e
wa0x6e merged commit a8b94eb into master Apr 1, 2026
2 checks passed
@wa0x6e
wa0x6e deleted the fix/alias-duplicate-check branch April 1, 2026 13:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants