Skip to content

Commit 19f1f63

Browse files
author
Mateusz
committed
Skip retired anthropic-oauth plugin entry point during discovery
Avoid AttributeError warnings when older llm-interactive-proxy-oauth-connectors metadata still declares the removed backend. Add unit test for silent skip. Made-with: Cursor
1 parent fa8fb2c commit 19f1f63

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/core/services/backend_plugin_discovery.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
ENTRY_POINT_GROUP = BACKEND_PLUGIN_ENTRY_POINT_GROUP
3333
_DEFAULT_CORE_VERSION = "0.1.0"
3434

35+
# Entry point names removed from optional oauth-connectors but still present in
36+
# older installed distributions; skip without loading or logging a failure.
37+
_RETIRED_BACKEND_PLUGIN_ENTRY_POINTS: frozenset[str] = frozenset({"anthropic-oauth"})
38+
3539

3640
def discover_plugin_backends(entry_point_group: str = ENTRY_POINT_GROUP) -> list[str]:
3741
"""Discover and register optional plugin backends.
@@ -58,6 +62,14 @@ def discover_plugin_backends(entry_point_group: str = ENTRY_POINT_GROUP) -> list
5862
plugin_load_error_first_ep: dict[tuple[str, str], str] = {}
5963
seen_backend_names: set[str] = set()
6064
for entry_point in entry_points:
65+
if entry_point.name in _RETIRED_BACKEND_PLUGIN_ENTRY_POINTS:
66+
if logger.isEnabledFor(logging.DEBUG):
67+
logger.debug(
68+
"Skipping retired backend plugin entry point %r.",
69+
entry_point.name,
70+
)
71+
continue
72+
6173
provider = _load_provider(entry_point, plugin_load_error_first_ep)
6274
if provider is None:
6375
continue

tests/unit/core/services/test_backend_plugin_discovery.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ def test_no_entry_points_is_valid_optional_absence(self) -> None:
6060

6161
assert discovered == []
6262

63+
def test_retired_entry_point_is_silently_skipped(self, caplog: Any) -> None:
64+
"""Stale setuptools metadata must not trigger load or WARNING."""
65+
retired = _entry_point(
66+
name="anthropic-oauth",
67+
load_error=RuntimeError("load must not be called for retired entry points"),
68+
)
69+
with (
70+
patch(
71+
"src.core.services.backend_plugin_discovery._resolve_core_version",
72+
return_value="0.1.0",
73+
),
74+
patch(
75+
"src.core.services.backend_plugin_discovery._load_entry_points",
76+
return_value=[retired],
77+
),
78+
caplog.at_level("WARNING"),
79+
):
80+
discovered = discover_plugin_backends()
81+
82+
assert discovered == []
83+
assert "Failed to load backend plugin entry point" not in caplog.text
84+
6385
def test_entry_point_load_failure_is_fail_open(self, caplog: Any) -> None:
6486
broken = _entry_point(
6587
name="broken-oauth", load_error=ImportError("Cannot import plugin module")

0 commit comments

Comments
 (0)