Enable Copilot BYOK provider-env fallback, base-path routing, and hardened token isolation#2598
Enable Copilot BYOK provider-env fallback, base-path routing, and hardened token isolation#2598
Conversation
|
@copilot make sure that auth tokens are never injected into the agent container |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (3 files)
Coverage comparison generated by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR updates the CLI’s Copilot BYOK env resolution so workflows that only set provider-style Copilot env vars can still activate the API proxy sidecar and derive a Copilot target for allowlisting/routing.
Changes:
- Added
resolveCopilotApiKey()to fall back fromCOPILOT_API_KEYtoCOPILOT_PROVIDER_API_KEY. - Added
deriveCopilotApiTargetFromProviderBaseUrl()and threaded its result into CLI config + allowlist resolution. - Added unit tests for env precedence and hostname derivation edge cases.
Show a summary per file
| File | Description |
|---|---|
src/cli.ts |
Adds Copilot BYOK env fallback helpers and uses the resolved target/key in CLI runtime config and allowlist setup. |
src/cli.test.ts |
Adds focused helper tests for Copilot env-key precedence and provider-base-URL hostname derivation. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
| const candidate = trimmed.includes('://') | ||
| ? trimmed | ||
| : `https://${trimmed}`; | ||
|
|
||
| try { | ||
| return new URL(candidate).hostname || undefined; |
| options.copilotApiTarget || | ||
| process.env.COPILOT_API_TARGET || | ||
| copilotApiTargetFromProviderBaseUrl; | ||
|
|
|
@copilot address review feedback |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Implemented in 48e065b. I hardened agent env filtering so |
Addressed in 9d0cb5d. I implemented Copilot provider base-path routing so |
|
Smoke Test Results Status: PASS
|
|
Smoke Test: Copilot BYOK — PR by
Running in BYOK offline mode ( Overall: PASS (core BYOK path confirmed working)
|
🔥 Smoke Test Results
Overall: PASS PR: Enable Copilot BYOK provider-env fallback, base-path routing, and hardened token isolation
|
|
🔮 Codex smoke oracle: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results
Overall: FAIL —
|
Chroot Version Comparison — Smoke Test Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot. Go versions match.
|
Copilot BYOK runs could fail when workflows set
COPILOT_PROVIDER_API_KEY/COPILOT_PROVIDER_BASE_URLwithoutCOPILOT_API_KEY: AWF did not activate Copilot sidecar BYOK routing, while one-shot token isolation still replaced the real key with a placeholder. This change aligns key/target/base-path resolution with provider-style envs so sidecar activation and upstream routing remain coherent.Copilot key resolution fallback
src/cli.tsnow resolvescopilotApiKeyfrom:COPILOT_API_KEYCOPILOT_PROVIDER_API_KEYCopilot target derivation from provider base URL
--copilot-api-targetandCOPILOT_API_TARGETare unset, CLI derivescopilotApiTargetfromCOPILOT_PROVIDER_BASE_URLhostname.Copilot base-path derivation and propagation from provider base URL
copilotApiBasePathfrom the path component ofCOPILOT_PROVIDER_BASE_URL(or usesCOPILOT_API_BASE_PATHwhen explicitly set).src/services/api-proxy-service.tsnow forwardsCOPILOT_API_BASE_PATHto the sidecar.containers/api-proxy/providers/copilot.jsnow applies the base path viagetBasePath()so BYOK providers using prefixed endpoints (for example/api/v1) are routed correctly instead of being sent to host root.Agent token isolation hardening (feedback follow-up)
--enable-api-proxyis enabled, agent env passthrough now explicitly excludes:COPILOT_GITHUB_TOKENCOPILOT_API_KEYCOPILOT_PROVIDER_API_KEY--env-all), while preserving explicit placeholder behavior used for compatibility.Focused unit coverage
clitests for:COPILOT_API_KEYoverCOPILOT_PROVIDER_API_KEY)agent-servicetests to verify:--env-allCOPILOT_API_BASE_PATHis forwarded by compose generation when configured