Refactor OpenAI BYOK base URL parsing to reuse shared proxy URL normalization#4949
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request refactors OpenAI Azure BYOK base URL parsing in the API proxy to reuse shared URL normalization/parsing logic in proxy-utils.js, reducing duplicated parsing behavior between providers and core utilities.
Changes:
- Introduces
parseApiTargetAndBasePath()incontainers/api-proxy/proxy-utils.jsbuilt on a shared internal URL parsing helper. - Updates the OpenAI provider to use the new shared parser instead of a provider-local
parseByokBaseUrl()implementation. - Adds/extends unit tests to cover the new shared parsing behavior and to ensure BYOK base URLs with path components do not trigger
console.warn.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/server.routing.test.js | Adds unit coverage for parseApiTargetAndBasePath() behavior. |
| containers/api-proxy/proxy-utils.js | Refactors normalizeApiTarget() to use a shared parser; adds parseApiTargetAndBasePath() and internal parseApiTargetUrl(). |
| containers/api-proxy/providers/openai.js | Removes provider-local BYOK URL parsing and switches to shared parseApiTargetAndBasePath(). |
| containers/api-proxy/oidc-token-provider.test.js | Adds a test ensuring BYOK base URLs with path/query don’t produce warnings during OpenAI adapter creation. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 2
| @@ -23,29 +23,70 @@ const { URL } = require('url'); | |||
| function normalizeApiTarget(value) { | |||
- JSDoc now documents that falsy values (including '') are returned as-is - Test name clarifies it covers path + query string, not just path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
Smoke Test: Copilot BYOK (Direct) Mode ✅All tests passed
Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY via api-proxy sidecar) Status: PASS
|
🔍 Smoke Test: API Proxy OpenTelemetry Tracing
All scenarios pass. OTEL tracing integration is complete: spans are created per request, token usage attributes follow GenAI semconv, parent context propagation is wired via env vars, and graceful degradation to file export works when no endpoint is configured.
|
🔬 Smoke Test ResultsPR: Refactor OpenAI BYOK base URL parsing to reuse shared proxy URL normalization
Overall: PASS (2/2 verifiable tests passed; file test skipped due to unexpanded workflow template)
|
|
Refactor OpenAI BYOK base URL parsing to reuse shared proxy URL normalization 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.
|
🧪 Chroot Version Comparison Results
Overall result: ❌ FAILED — Python and Node.js versions differ between host and chroot environments.
|
|
Smoke Test Results:
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL).
|
Smoke Test: Gemini Engine Validation
✅ GitHub MCP Testing Overall status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
🔥 Smoke Test: PAT Auth — PASSAuth mode: PAT (COPILOT_GITHUB_TOKEN)
Overall: PASS
|
|
Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra Overall: FAIL
|
Smoke Test: GitHub Actions Services Connectivity
Overall: ❌ FAIL
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
providers/openai.jshad a localparseByokBaseUrl()that duplicated the core URL normalization logic already implemented inproxy-utils.js(schemedetection, implicithttps://,URLparse/hostname extraction). This centralizes that parsing path to avoid drift while preserving BYOK-specific path handling.Shared parsing primitive in
proxy-utilsparseApiTargetAndBasePath(value)to return{ target, basePath }from a single parse pass.normalizeApiTargetvia an internal shared parser.OpenAI provider now consumes shared utility
parseByokBaseUrl()fromproviders/openai.js.parseApiTargetAndBasePath(env.COPILOT_PROVIDER_BASE_URL).Behavioral intent preserved
normalizeApiTargetretains warning behavior for unsupported URL components.