-
Notifications
You must be signed in to change notification settings - Fork 2
fix: demo CLI discovery fallback for uninstalled source checkouts #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Coding-Dev-Tools
wants to merge
3
commits into
master
Choose a base branch
from
cowork/fix-demo-discovery-fallback
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
5a9c209
cowork-bot: fix demo CLI discovery fallback for uninstalled source ch…
Coding-Dev-Tools 08d9d76
cowork-bot: add diagnostic logging to discover.py silent exception ha…
Coding-Dev-Tools c4177ed
ci: SHA-pin all actions/checkout@v4 to immutable 11d5960 (supply-chai…
Coding-Dev-Tools File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| """Tests for observability in discover.py — silent exception handlers should log.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
|
|
||
| from click_to_mcp.discover import ( | ||
| find_our_clis, | ||
| import_cli, | ||
| load_cli, | ||
| scan_entry_points, | ||
| ) | ||
|
|
||
|
|
||
| class TestDiscoverLogging: | ||
| """Verify that silent exception paths emit diagnostic log messages.""" | ||
|
|
||
| def test_scan_entry_points_logs_load_failure(self, caplog: pytest.LogCaptureFixture) -> None: | ||
| """scan_entry_points should log when an entry point fails to load.""" | ||
| fake_ep = MagicMock() | ||
| fake_ep.name = "broken-cli" | ||
| fake_ep.module = "nonexistent.module" | ||
| fake_ep.attr = "cli" | ||
| fake_ep.dist = None | ||
| fake_ep.load.side_effect = ImportError("no module named 'nonexistent'") | ||
|
|
||
| with patch("click_to_mcp.discover.entry_points") as mock_eps: | ||
| mock_eps.return_value.select.return_value = [fake_ep] | ||
| with caplog.at_level(logging.DEBUG, logger="click_to_mcp.discover"): | ||
| result = scan_entry_points() | ||
|
|
||
| assert result == [] | ||
| assert any("broken-cli" in r.message for r in caplog.records) | ||
|
|
||
| def test_load_cli_logs_entry_point_failure(self, caplog: pytest.LogCaptureFixture) -> None: | ||
| """load_cli should log when an entry point load raises.""" | ||
| fake_ep = MagicMock() | ||
| fake_ep.name = "my-broken-tool" | ||
| fake_ep.load.side_effect = RuntimeError("entry point crashed") | ||
|
|
||
| with patch("click_to_mcp.discover.entry_points") as mock_eps: | ||
| mock_eps.return_value.select.return_value = [fake_ep] | ||
| with caplog.at_level(logging.DEBUG, logger="click_to_mcp.discover"): | ||
| result = load_cli("my-broken-tool") | ||
|
|
||
| assert result is None | ||
| assert any("my-broken-tool" in r.message for r in caplog.records) | ||
|
|
||
| def test_import_cli_logs_import_failure(self, caplog: pytest.LogCaptureFixture) -> None: | ||
| """import_cli should log when module import fails.""" | ||
| with caplog.at_level(logging.DEBUG, logger="click_to_mcp.discover"): | ||
| result = import_cli("totally.fake.module.xyz", "app") | ||
|
|
||
| assert result is None | ||
| assert any("totally.fake.module.xyz" in r.message for r in caplog.records) | ||
|
|
||
| def test_find_our_clis_logs_load_failure(self, caplog: pytest.LogCaptureFixture) -> None: | ||
| """find_our_clis should log when a known-module entry point fails to load.""" | ||
| fake_ep = MagicMock() | ||
| fake_ep.name = "json2sql" | ||
| fake_ep.module = "json2sql.cli" | ||
| fake_ep.load.side_effect = AttributeError("missing attr") | ||
|
|
||
| with patch("click_to_mcp.discover.entry_points") as mock_eps: | ||
| mock_eps.return_value.select.return_value = [fake_ep] | ||
| with caplog.at_level(logging.DEBUG, logger="click_to_mcp.discover"): | ||
| result = find_our_clis() | ||
|
|
||
| assert result == {} | ||
| assert any("json2sql" in r.message for r in caplog.records) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SHA
11d5960a326750d5838078e36cf38b85af677262is not a valid commit inactions/checkout(the v4.2.2 commit is11bd71901bbe5b1630ceea73d27597364c9af683), so GitHub cannot resolve this action and the job stops before checkout. The same invalid pin is introduced in bothci.ymljobs and inpages.yml,publish.yml, andcowork-auto-pr.yml, disabling the repository's CI, deployment, publishing, and automatic-PR workflows until the reference is corrected.AGENTS.md reference: AGENTS.md:L28-L31
Useful? React with 👍 / 👎.