Skip to content

fix(api): provider endpoint mismatches preventing copilot save#511

Open
ibhagwan wants to merge 1 commit intospacedriveapp:mainfrom
ibhagwan:fix/copilot-provider-endpoints
Open

fix(api): provider endpoint mismatches preventing copilot save#511
ibhagwan wants to merge 1 commit intospacedriveapp:mainfrom
ibhagwan:fix/copilot-provider-endpoints

Conversation

@ibhagwan
Copy link
Copy Markdown
Contributor

Fix #415

And remove three endpoint mismatches between frontend and backend caused the GitHub Copilot provider's save, test, and remove buttons to fail with 405 Method Not Allowed. These affected all providers for save.

  • change update_provider annotation from post to put to match frontend
  • fix test button URL from /providers/test to /providers/test-model
  • add github-copilot entry in build_test_llm_config since default_provider_config returns None for providers that require token exchange
  • widen GITHUB_COPILOT_DEFAULT_BASE_URL visibility to pub(crate)
  • add unit test for build_test_llm_config with github-copilot

fix(api): Copilot provider shows as available after remove when env var is set

get_providers fell back to the GITHUB_COPILOT_API_KEY env var when the TOML key was absent, so the provider stayed visible in settings after a remove — the env var can't be unset from a running process.

Only check the TOML key for Copilot status in the config-exists path. The env var fallback remains for the no-config-file case (fresh install).

… and remove

Fix spacedriveapp#415

Three endpoint mismatches between frontend and backend caused the
GitHub Copilot provider's save, test, and remove buttons to fail
with 405 Method Not Allowed. These affected all providers for save.

- change update_provider annotation from post to put to match frontend
- fix test button URL from /providers/test to /providers/test-model
- add github-copilot entry in build_test_llm_config since
  default_provider_config returns None for providers that require
  token exchange
- widen GITHUB_COPILOT_DEFAULT_BASE_URL visibility to pub(crate)
- add unit test for build_test_llm_config with github-copilot

fix(api): Copilot provider shows as available after remove when env var is set

get_providers fell back to the GITHUB_COPILOT_API_KEY env var when the
TOML key was absent, so the provider stayed visible in settings after
a remove — the env var can't be unset from a running process.

Only check the TOML key for Copilot status in the config-exists path.
The env var fallback remains for the no-config-file case (fresh install).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7172b49-ceaa-49e1-b924-59b36e20ec5f

📥 Commits

Reviewing files that changed from the base of the PR and between b7d5dd2 and a9eba5d.

📒 Files selected for processing (4)
  • interface/src/api/client.ts
  • src/api/providers.rs
  • src/config.rs
  • src/config/providers.rs

Walkthrough

Updates GitHub Copilot provider registration logic in LLM test configuration, modifies provider availability detection to prioritize TOML config over environment variables, changes the provider update route from POST to PUT, and adjusts visibility of GitHub Copilot configuration constants.

Changes

Cohort / File(s) Summary
Frontend Endpoint
interface/src/api/client.ts
Updated api.testProviderModel to post to /providers/test-model endpoint instead of /providers/test.
GitHub Copilot Provider Registration
src/api/providers.rs
Extended build_test_llm_config to dynamically register github-copilot provider when config returns None, using OpenAI chat completions API type with default base URL and bearer authentication; added corresponding unit test.
Provider Availability Detection
src/api/providers.rs
Updated get_providers to determine github-copilot availability based solely on TOML llm.github_copilot_key (resolved via resolve_value), removing environment variable consideration when config file exists.
Provider Update Route
src/api/providers.rs
Changed update_provider route method from post to put in utoipa path decorator.
Configuration Constant Visibility
src/config.rs, src/config/providers.rs
Widened visibility of GITHUB_COPILOT_DEFAULT_BASE_URL from pub(super) to pub(crate) and re-exported it in src/config.rs for crate-wide access.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing provider endpoint mismatches that prevented Copilot save functionality.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, detailing all endpoint mismatches, visibility changes, and configuration fixes for GitHub Copilot provider.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #415: fixes endpoint mismatches (POST→PUT, /test→/test-model), adds github-copilot to build_test_llm_config, fixes provider visibility after removal, and widens constant visibility.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue objectives: endpoint fixes, LLM config extension for github-copilot, provider availability detection updates, and constant visibility widening are all in scope.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vsumner
Copy link
Copy Markdown
Collaborator

vsumner commented Mar 29, 2026

Review Summary

P2 Suggestion (non-blocking)

The Copilot special case in build_test_llm_config duplicates provider construction logic. Consider extracting a shared helper or documenting why default_provider_config can't handle this pattern.

P3 Architecture Note

The sandbox refactoring (deleting detection.rs and 4 test files) appears unrelated to the Copilot endpoint fixes. If this is intentional cleanup, it should ideally be a separate PR for cleaner history.

@ibhagwan
Copy link
Copy Markdown
Contributor Author

P3 Architecture Note
The sandbox refactoring (deleting detection.rs and 4 test files) appears unrelated to the Copilot endpoint fixes. If this is intentional cleanup, it should ideally be a separate PR for cleaner history.

This PR does not modify detection.rs at all, probably a local leftover during the review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Github Copilot provider not working

2 participants