Conversation
Effi-S
marked this pull request as ready for review
August 10, 2026 13:00
Effi-S
force-pushed
the
fix-2063
branch
2 times, most recently
from
August 10, 2026 14:18
9f855b1 to
ae3090b
Compare
AkramBitar
requested changes
Aug 11, 2026
Effi-S
force-pushed
the
fix-2063
branch
4 times, most recently
from
August 12, 2026 16:15
88787f5 to
32c7544
Compare
… an empty string issue Signed-off-by: Effi-S <effi.szt@gmail.com>
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.
Fixes #2063
Summary
Registry.GetWalletIDswallows every storage error and returns("", nil), which its callers treatidentically to "no wallet is bound to this identity." A transient storage error (DB blip, timeout)
therefore looks exactly like "not registered yet," and the wallet-lookup fallback chain in
Lookupcreates a brand-new wallet and a second identity binding for an identity that already has one.
Where
token/services/identity/role/registry.go:237-246:All three call sites treat
err == nil && len(wID) == 0as "not found, try the next fallback":registry.go:85-92,registry.go:114-117,registry.go:131-133.Impact
Lookup(registry.go:72-166) is the fallback path used byWalletByID(registry.go:271-281)whenever the in-memory cache misses. If the storage-level
GetWalletIDcall fails transiently (not"no row found," but an actual error — timeout, connection reset, etc.), the registry cannot
distinguish that from "this identity has never been registered." It falls through to
WalletFactory.NewWallet(registry.go:293), creating a second wallet and a second identity→walletbinding for the same identity. This duplicates wallet state and, depending on the wallet
implementation, can duplicate key material bookkeeping.
Reproduction
Not yet committed. Mock
idriver.WalletStoreService.GetWalletIDto return a non-nil error (e.g. asimulated transient DB error) on the first call for an identity that has a real binding, and a
successful lookup on a second, independent call. Assert
Registry.GetWalletIDpropagates the errorrather than returning
("", nil), and thatWalletByIDdoes not create a duplicate wallet when theunderlying storage error is transient.
Suggested fix
Propagate the error and let callers decide:
This requires updating the three call sites in
Lookupto distinguish "storage error" (abort/retry)from "no row found" (continue to the next fallback) — today they're merged into one case. This
should land together with #8 (
WalletByIDwrite-lock scope), since both touch the samecreation path and fixing one without the other leaves the duplicate-wallet risk only partially
addressed.
Severity
MEDIUM — requires a transient storage failure to trigger, but results in persisted duplicate wallet
state, which is hard to reconcile after the fact.