From d9165d7a678d4105f42921a7fc1886df3804531b Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 23 Jul 2026 08:36:11 -0700 Subject: [PATCH] fix: resolve current entry unlocked in try_refresh_matching no-hint branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to the #62614 salvage: try_refresh_matching (added by the #69843 salvage after this PR's base) calls self.current() while already holding the now-locking non-reentrant pool lock — a guaranteed deadlock that git merges silently (no textual conflict). Use _current_unlocked() and cover the method in the no-deadlock test. --- agent/credential_pool.py | 2 +- tests/agent/test_credential_pool.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/agent/credential_pool.py b/agent/credential_pool.py index 0bc113746c..d5d652ad74 100644 --- a/agent/credential_pool.py +++ b/agent/credential_pool.py @@ -1907,7 +1907,7 @@ class CredentialPool: None, ) else: - entry = self.current() or self._select_unlocked(refresh=False) + entry = self._current_unlocked() or self._select_unlocked(refresh=False) if entry is None: return None self._current_id = entry.id diff --git a/tests/agent/test_credential_pool.py b/tests/agent/test_credential_pool.py index 4fbe23efe5..f872b5a509 100644 --- a/tests/agent/test_credential_pool.py +++ b/tests/agent/test_credential_pool.py @@ -3619,6 +3619,11 @@ class TestCredentialPoolQueryLocking: assert pool.resolve_target("cred-1")[1] is not None # (env may seed extra singleton entries; just assert ours are present) assert {"cred-1", "cred-2"} <= {e.id for e in pool.entries()} + # try_refresh_matching's no-hint branch resolves the current entry + # while already holding the lock — must use _current_unlocked(), not + # current(), or it deadlocks on the non-reentrant lock (found when + # rebasing this fix over the #69843 salvage which added the method). + pool.try_refresh_matching() @pytest.mark.parametrize( "method,get_args",