fix: Copilot adapter validates remote transport_type (#791)#812
Open
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: Copilot adapter validates remote transport_type (#791)#812mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Mirror PR microsoft#656 in the Copilot adapter. Reject unrecognized remote transports (e.g. 'grpc') with a clear ValueError, default to 'http' when the registry omits transport_type, and skip remote entries without URLs. Copilot CLI still emits 'type': 'http' for every remote per its spec -- only the validation surface changes. Adds a new tests/unit/test_copilot_adapter.py suite parallel to tests/unit/test_vscode_adapter.py, covering missing/empty/whitespace/ None transport, the raise-on-unsupported path, the supported transport set, and the _select_remote_with_url helper. Fixes microsoft#791
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.
Description
Resolves #791.
Mirrors PR #656 in the Copilot adapter. The Copilot client currently accepts any
transport_typevalue (or none) from registry remotes without validation, so a registry entry returningtransport_type: "grpc"would silently produce a garbage config instead of failing loud.After this change,
src/apm_cli/adapters/client/copilot.py:_select_remote_with_url, mirrorsvscode.py:_select_remote_with_url), falling back to the original behavior when no remote has a URL so the downstream empty-URL error path is preserved.transport_type, strips whitespace, defaults to"http"when missing/empty/whitespace-only, and raisesValueErrorfor non-empty unrecognized transports with the same message shape as the VS Code adapter:"type": "http"in the final Copilot CLI config (Copilot spec requirement for auth) and now strips the URL via.strip().The helper is a
@staticmethodonCopilotClientAdapterfor now; promoting it to a shared base (per the issue's point #3) is left for a follow-up so this PR stays scoped.Type of change
Testing
uv run pytest tests/unit/ -q→ 3715 passed)New test file
tests/unit/test_copilot_adapter.py(parallel totest_vscode_adapter.py):test_remote_missing_transport_type_defaults_to_httptest_remote_empty_transport_type_defaults_to_httptest_remote_none_transport_type_defaults_to_httptest_remote_whitespace_transport_type_defaults_to_httptest_remote_unsupported_transport_raises(asserts message includes transport name, server name, and "Copilot")test_remote_supported_transports_do_not_raise(parametrized overhttp,sse,streamable-http)test_remote_skips_entries_without_url_select_remote_with_urlTotal: 10 new tests, all passing. Full
tests/unit/suite passes unchanged.Fixes #791