Files
pad/internal/server
xarmian 812f68930b fix(store): an unlink re-checks that a sign-in method remains under the account lock (BUG-3816) (#2191)
* fix(store): an unlink re-checks that a sign-in method remains under the account lock (BUG-3816)

handleOAuthUnlink checked "another provider or a password remains" against
the account as it was when the request was admitted, so two unlinks of
different providers sent at once both passed and the second wrote an empty
provider list. RemoveOAuthProvider now runs the check on the locked row and
refuses with ErrLastSignInMethod, which the handler maps to the existing 400.
A repeat unlink of a provider no longer linked stays a no-op.

Claude-Session: https://claude.ai/code/session_01Rj4CMyK2EqxerMihbGs3Kr

* test(server): the TASK-3351 unlink test keeps a second sign-in method (BUG-3816)

It unlinked the account's only provider to check the binding is forgotten,
which the locked last-method check now refuses. It links github first, so
it stays about the binding.

Claude-Session: https://claude.ai/code/session_01Rj4CMyK2EqxerMihbGs3Kr

* test(store): the concurrent unlink pin waits for the unlink's own lock read (BUG-3816)

It counted any lock wait in the database as the overlap. It now matches the
backend whose current query is the account row's FOR NO KEY UPDATE read,
the class codex r1 found in BUG-3817's race test.

Claude-Session: https://claude.ai/code/session_01Rj4CMyK2EqxerMihbGs3Kr
2026-10-15 17:23:24 -04:00
..