Skip to content

fix: Copilot adapter validates remote transport_type (#791)#812

Open
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn:fix-copilot-transport-validation-791
Open

fix: Copilot adapter validates remote transport_type (#791)#812
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn:fix-copilot-transport-validation-791

Conversation

@mvanhorn
Copy link
Copy Markdown

Description

Resolves #791.

Mirrors PR #656 in the Copilot adapter. The Copilot client currently accepts any transport_type value (or none) from registry remotes without validation, so a registry entry returning transport_type: "grpc" would silently produce a garbage config instead of failing loud.

After this change, src/apm_cli/adapters/client/copilot.py:

  1. Selects the first remote with a non-empty URL (_select_remote_with_url, mirrors vscode.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.
  2. Reads transport_type, strips whitespace, defaults to "http" when missing/empty/whitespace-only, and raises ValueError for non-empty unrecognized transports with the same message shape as the VS Code adapter:

    Unsupported remote transport '{transport}' for Copilot. Server: {name}. Supported transports: http, sse, streamable-http.

  3. Still emits "type": "http" in the final Copilot CLI config (Copilot spec requirement for auth) and now strips the URL via .strip().

The helper is a @staticmethod on CopilotClientAdapter for 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

  • Bug fix

Testing

  • Tested locally
  • All existing tests pass (uv run pytest tests/unit/ -q → 3715 passed)
  • Added tests for new functionality

New test file tests/unit/test_copilot_adapter.py (parallel to test_vscode_adapter.py):

  • test_remote_missing_transport_type_defaults_to_http
  • test_remote_empty_transport_type_defaults_to_http
  • test_remote_none_transport_type_defaults_to_http
  • test_remote_whitespace_transport_type_defaults_to_http
  • test_remote_unsupported_transport_raises (asserts message includes transport name, server name, and "Copilot")
  • test_remote_supported_transports_do_not_raise (parametrized over http, sse, streamable-http)
  • test_remote_skips_entries_without_url
  • 3 direct unit tests on _select_remote_with_url

Total: 10 new tests, all passing. Full tests/unit/ suite passes unchanged.

Fixes #791

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
@danielmeppiel danielmeppiel added the panel-review Trigger the apm-review-panel gh-aw workflow label Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

panel-review Trigger the apm-review-panel gh-aw workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot adapter: add symmetric transport_type validation (mirror #656)

2 participants