feat: support base path prefix for OpenAI and Anthropic API targets#1369
feat: support base path prefix for OpenAI and Anthropic API targets#1369
Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 86.05% | 86.11% | 📈 +0.06% |
| Statements | 85.97% | 86.03% | 📈 +0.06% |
| Functions | 86.13% | 86.13% | ➡️ +0.00% |
| Branches | 79.21% | 78.89% | 📉 -0.32% |
📁 Per-file Coverage Changes (1 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/docker-manager.ts |
87.4% → 87.7% (+0.25%) | 86.8% → 87.0% (+0.23%) |
Coverage comparison generated by scripts/ci/compare-coverage.ts
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
#1370) * Initial plan * fix: add tests for api-base-path feature to fix coverage regression --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
|
@copilot can you make sure that there are robust test cases for preserving path info in custom api targets? |
This comment has been minimized.
This comment has been minimized.
Smoke Test Results
Last 2 merged PRs:
Overall: PASS
|
Chroot Version Comparison Results
Result: FAILED — Python and Node.js versions differ between host and chroot environments.
|
Added Tests cover:
|
|
Smoke test results — Run 23311114087
Overall: PASS
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds support for API targets that require a path prefix (e.g., Databricks, Azure-style gateways) by allowing OpenAI/Anthropic requests to be forwarded with an optional upstream base path, configured via CLI/env and propagated into the api-proxy sidecar.
Changes:
- Add
OPENAI_API_BASE_PATH/ANTHROPIC_API_BASE_PATHsupport in the api-proxy and helper functions for upstream path construction. - Expose new CLI flags and config fields for specifying base path prefixes, and pass them into the api-proxy container env.
- Add/extend unit tests for upstream path building and docker-compose env propagation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
containers/api-proxy/server.js |
Adds base-path normalization and upstream path construction; wires base paths into OpenAI/Anthropic proxy handlers. |
containers/api-proxy/server.test.js |
Adds unit tests for normalizeBasePath and buildUpstreamPath. |
src/types.ts |
Extends WrapperConfig with optional base path properties for OpenAI/Anthropic. |
src/cli.ts |
Adds --openai-api-base-path / --anthropic-api-base-path flags and maps them into config. |
src/docker-manager.ts |
Propagates base path env vars into api-proxy container and logs configuration. |
src/docker-manager.test.ts |
Adds tests for base path env propagation (and minor UID/GID validation test coverage improvements). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…1372) * Initial plan * fix: update flatted to 3.4.2 to resolve high severity prototype pollution vulnerability Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
|
Smoke Test Results — Run #23312074359 ✅ GitHub MCP — Last 2 merged PRs: #1372 "fix: resolve high severity flatted prototype pollution vulnerability", #1370 "[WIP] Fix the failing GitHub Actions workflow for test coverage report" Overall: PASS | Author:
|
Chroot Version Comparison Results
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
🔮 The oracle records this smoke pass for PR #1369.
Warning
|
|
Smoke Test Results ✅ GitHub MCP: #1372 fix: resolve high severity flatted prototype pollution vulnerability, #1370 [WIP] Fix the failing GitHub Actions workflow for test coverage report Overall: PASS
|
Summary
Fixes the issue where
OPENAI_BASE_URLorANTHROPIC_BASE_URLvalues with a required path prefix (e.g. Databricks/serving-endpoints, Azure OpenAI/openai/deployments/<name>) silently fail because the api-proxy sidecar drops the path component when forwarding requests.Root Cause
proxyRequest()incontainers/api-proxy/server.jsusedreq.urldirectly as the upstream path (e.g./v1/chat/completions) with no way to prepend a base path. When a custom target host requires a path prefix, the request lands at the wrong endpoint and returns 404.Changes
containers/api-proxy/server.jsnormalizeBasePath(rawPath)helper that ensures a leading/and strips trailing/buildUpstreamPath(reqUrl, targetHost, basePath)as a pure helper that constructs the full upstream path; used byproxyRequest()OPENAI_API_BASE_PATHandANTHROPIC_API_BASE_PATHenv vars (default"")basePath6th parameter toproxyRequest(); prepends it to the upstream request path viabuildUpstreamPath()proxyRequest()for the OpenAI and Anthropic handlersnormalizeBasePathandbuildUpstreamPathfor unit testingcontainers/api-proxy/server.test.jsnormalizeBasePathbuildUpstreamPathcovering: no base path, Databricks/serving-endpoints, Azure OpenAI multi-segment deployment paths, Anthropic custom base paths, query string preservation, URL-encoded characters, hash fragment handling, and real-world standard endpointssrc/types.ts— addsopenaiApiBasePath?: stringandanthropicApiBasePath?: stringtoWrapperConfigsrc/cli.ts— adds--openai-api-base-path <path>and--anthropic-api-base-path <path>options; maps them into config (also readable fromOPENAI_API_BASE_PATH/ANTHROPIC_API_BASE_PATHenv vars)src/docker-manager.ts— passes the base path env vars to the api-proxy container and logs them at debug levelUsage Example
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.