Skip to content

fix: wallet disconnect fails silently — add DELETE /users/:id/stellar-address (#714) - #718

Merged
chonilius merged 2 commits into
mainfrom
fix/714-wallet-disconnect-null-validation
Oct 29, 2026
Merged

chonilius merged 2 commits into
mainfrom
fix/714-wallet-disconnect-null-validation

Conversation

@chonilius

Copy link
Copy Markdown
Contributor

Summary

Closes #714

Root cause: disconnect() on the frontend calls PATCH /users/:id/stellar-address with { stellarAddress: null }. The @IsStellarAddress() validator on SetStellarAddressDto runs StrKey.isValidEd25519PublicKey(null) which always returns false, so the backend returns 400 Bad Request. The .catch(() => {}) in disconnect() swallowed the error completely, leaving AuthUser.stellarAddress set on the backend while the local UI appeared disconnected.

Fix (backend — this PR):

  • Adds DELETE /users/:id/stellar-address — a dedicated unlink route that accepts no body and sets stellarAddress = null via a new clearStellarAddress() service method.
  • Keeps PATCH :id/stellar-address strictly typed for real StrKey-validated addresses; the two operations have distinct semantics and should not share a DTO.
  • Adds tests in users.service.spec.ts (NotFoundException + null-write) and users.controller.spec.ts (happy path + 403 cross-user rejection).

Frontend fix is raised in a companion PR on the frontend repo — changes disconnect() to call DELETE instead of PATCH { stellarAddress: null } and surfaces backend errors to the console instead of silently discarding them.

Test plan

  • npm run test — new clearStellarAddress service and controller specs pass
  • DELETE /users/:id/stellar-address as the address owner → 200, stellarAddress: null in response
  • DELETE /users/:id/stellar-address as a different authenticated user → 403
  • PATCH /users/:id/stellar-address with { stellarAddress: null } still returns 400 (existing validator unchanged)

…714)

PATCH { stellarAddress: null } always returned 400 because the
@IsStellarAddress() validator on SetStellarAddressDto only accepts a
valid Stellar Ed25519 public key — null never passes StrKey validation.
The disconnect() call on the frontend was silently swallowed by its
.catch(() => {}) so the failure was invisible to users and maintainers.

Adds a dedicated DELETE :id/stellar-address route that accepts no body
and sets user.stellarAddress to null via a new clearStellarAddress()
service method, keeping the PATCH route strictly typed for real
addresses.
#714)

Adds two spec blocks:
- users.service.spec.ts: NotFoundException on missing user; null written
  to stellarAddress and persisted via userRepo.save.
- users.controller.spec.ts: wires the clearStellarAddress mock; asserts
  the happy path returns stellarAddress: null and the cross-user attempt
  throws ForbiddenException without calling the service.
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
merge-fi-backend Error Error Oct 29, 2026 8:04pm UTC

@chonilius
chonilius merged commit c6a6311 into main Oct 29, 2026
3 of 5 checks passed

This branch had an error being deployed

1 failed deployment
Preview — 4bc7a9d8 Deployed Oct 29, 2026 by vercel[bot]
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.

1 participant