refactor: eliminate duplicate provider env-var constants via JSON single source of truth#5869
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the API-proxy provider env-var constants to remove duplicated definitions between the TypeScript host code and the CommonJS API-proxy sidecar by introducing a single JSON source of truth, reducing drift risk in credential routing.
Changes:
- Add
containers/api-proxy/provider-env-constants.jsonas the authoritative mapping for provider env-var constant objects. - Simplify the sidecar’s
provider-env-constants.jsto re-export the JSON, and update the api-proxy Dockerfile to copy the new JSON into the image. - Update the host’s
src/api-proxy-env-constants.tsto load the same JSON and re-export the constants; adjust the sync test description accordingly.
Show a summary per file
| File | Description |
|---|---|
| src/api-proxy-env-constants.ts | Switches host constants to load/re-export from the shared JSON definition. |
| src/api-proxy-env-constants-sync.test.ts | Updates the test description to reflect the new “shared JSON source” approach. |
| containers/api-proxy/provider-env-constants.json | Introduces the shared provider env-var constants definition. |
| containers/api-proxy/provider-env-constants.js | Reduces sidecar constants module to a JSON re-export. |
| containers/api-proxy/Dockerfile | Ensures the new JSON file is included in the api-proxy image build context via explicit COPY. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Low
| // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
| const _providerEnvConstants = require('../containers/api-proxy/provider-env-constants.json') as { | ||
| OPENAI_ENV: { KEY: string; TARGET: string; BASE_PATH: string; AUTH_HEADER: string }; | ||
| ANTHROPIC_ENV: { KEY: string; TARGET: string; BASE_PATH: string; AUTH_HEADER: string }; | ||
| GEMINI_ENV: { KEY: string; TARGET: string; BASE_PATH: string }; | ||
| COPILOT_ENV: { | ||
| GITHUB_TOKEN: string; | ||
| PROVIDER_API_KEY: string; | ||
| PROVIDER_TYPE: string; | ||
| PROVIDER_BASE_URL: string; | ||
| API_TARGET: string; | ||
| API_BASE_PATH: string; | ||
| }; | ||
| }; |
|
@copilot address review feedback |
|
✅ Copilot review passed with no inline comments. @copilot Add the |
|
✅ Smoke Gemini completed. All facets verified. 💎 |
|
✅ Build Test Suite completed successfully! |
|
❌ Security Guard failed. Please review the logs for details. |
|
🔌 Smoke Services — All services reachable! ✅ |
|
✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓 |
|
✅ Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓 |
|
✅ Smoke Claude passed |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
✅ Contribution Check completed successfully! PR #5869 follows the applicable CONTRIBUTING.md guidelines based on the provided context; no comment needed. |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
Chroot tests failed Smoke Chroot failed - See logs for details. |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
Smoke Test: Claude Engine Validation
Overall Result: PASS ✅ Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
Smoke Test (Direct BYOK → Azure OpenAI Foundry, o4-mini-aw)\n\n- MCP PR list: ✅\n- github.com connectivity: ✅\n- File I/O: ✅\n- BYOK inference: ✅\n\nOverall: PASS\n\ncc Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test Results
Overall: FAIL — Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Copilot BYOK Mode ✅
Status: PASS Running in direct BYOK mode with placeholder credentials. Inference requests routed through sidecar. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
refactor: eliminate duplicate provider env-var constants via JSON single source of truth Warning Firewall blocked 2 domainsThe following domains were blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"
- "registry.npmjs.org"See Network Configuration for more information.
|
🔍 Smoke Test Results
Overall: FAIL —
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Copilot PAT Auth — PASS ✅
Auth mode: PAT (COPILOT_GITHUB_TOKEN) cc Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Gemini Smoke Test Results
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.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS Details
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
🔭 Smoke Test: API Proxy OpenTelemetry Tracing
All verifiable scenarios passed. OTEL integration is functional. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
Recent merged PRs: chore: fix 3 moderate CVEs via dep updates (2026-07-03); fix: drop workDir-adjacent chroot-home mount on split-fs sysroot. Tests: MCP ✅, GitHub.com ✅, file I/O ✅, BYOK inference ✅. 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. Status: PASS. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
The 30 API proxy provider env-var constants (
OPENAI_ENV,ANTHROPIC_ENV,GEMINI_ENV,COPILOT_ENV) were manually duplicated betweensrc/api-proxy-env-constants.tsandcontainers/api-proxy/provider-env-constants.js. Drift between the two could silently break credential routing in the security-critical API proxy sidecar.Changes
containers/api-proxy/provider-env-constants.json(new) — single authoritative definition of all four provider constant objectscontainers/api-proxy/provider-env-constants.js— reduced tomodule.exports = require('./provider-env-constants.json')src/api-proxy-env-constants.ts— replaces duplicatedas constobjects with arequire()of the JSON; TypeScript infers literal string types from JSON, preserving the same type guarantees; OIDC mapping is unchangedcontainers/api-proxy/Dockerfile— addsprovider-env-constants.jsonto the explicitCOPYlist (thedockerfile-copy-coverageguard test enforces this)src/api-proxy-env-constants-sync.test.ts— test description updated to reflect that parity is now structurally guaranteed rather than a checked invariant