fix: ignore 404 when deleting a lightning address (#2323) (#2410)

fix: ignore 404 when deleting an already-deleted lightning address (#2323)

When a sub-wallet's lightning address was already removed on getalby.com, the DELETE call returns 404, which surfaced as a "Failed to delete lightning address" error toast. Treat 404 as success so deletion is idempotent.
This commit is contained in:
Alchemist 2026-06-08 08:17:20 +01:00 committed by GitHub
parent 5c23375c08
commit d2acf9ccb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -418,6 +418,13 @@ func (svc *albyOAuthService) DeleteLightningAddress(ctx context.Context, address
return errors.New("failed to read response body")
}
if res.StatusCode == http.StatusNotFound {
// The lightning address was already deleted on the Alby account
// (e.g. removed previously). Treat as success so deletion is idempotent.
logger.Logger.WithField("address", address).Info("Lightning address already deleted on Alby account, ignoring 404")
return nil
}
if res.StatusCode >= 300 {
return fmt.Errorf("DELETE request to /internal/lightning_addresses/%s returned non-success status: %d %s", address, res.StatusCode, string(responseBody))
}