Deduplicate API proxy config env lookup and auth type normalization#4338
Conversation
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
Smoke Test: Claude Engine
Result: PASS
|
There was a problem hiding this comment.
Pull request overview
This PR refactors API-proxy-related environment/config lookups by centralizing duplicated config/env precedence logic and auth-type normalization into src/env-utils.ts, then updating the two API proxy service modules to reuse those helpers. It also expands unit tests to cover the shared helpers’ precedence, trimming, envAll gating, and lowercasing behavior.
Changes:
- Moved duplicated
getConfigEnvValuelogic intosrc/env-utils.tsand added shared normalization helpers. - Updated API proxy service config and credential env modules to use the shared helpers (including normalized
AWF_AUTH_TYPE/AWF_AUTH_PROVIDERreads). - Added unit tests covering config env precedence/trimming and lowercased process env normalization.
Show a summary per file
| File | Description |
|---|---|
| src/services/api-proxy-service-config.ts | Removes local env lookup + normalizes auth type via shared helpers. |
| src/services/api-proxy-credential-env.ts | Removes local env lookup + normalizes auth type/provider via shared helpers. |
| src/env-utils.ts | Adds shared env value normalization and config/env precedence helper functions. |
| src/env-utils.test.ts | Adds focused unit coverage for new env-utils helpers (precedence, trimming, envAll gating, lowercasing). |
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: 0
|
🤖 Smoke Test Results — run 26985549659
Overall: PASS PR: Deduplicate API proxy config env lookup and auth type normalization — author
|
|
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.
|
🔑 Smoke Test: Copilot BYOK (Direct) — PASS
PR: Deduplicate API proxy config env lookup and auth type normalization — Running in direct BYOK mode (
|
🧪 Chroot Smoke Test Results
Overall: ❌ FAILED — Python and Node.js versions differ between host and chroot environments.
|
|
Gemini Smoke Test: FAIL (Connectivity 400/35, MCP missing, FS/Bash OK) 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
|
Smoke Test Results
Overall: FAIL
|
The API proxy split left two sibling service modules with byte-for-byte copies of
getConfigEnvValue, plus duplicatedAWF_AUTH_TYPEnormalization. This made env precedence changes easy to miss and kept auth-path logic duplicated across the credential and service config paths.Shared env/config helpers
getConfigEnvValueintosrc/env-utils.tsadditionalEnv -> envFile -> process.env (when envAll)API proxy services
getConfigEnvValuecopies from:src/services/api-proxy-credential-env.tssrc/services/api-proxy-service-config.tsAWF_AUTH_TYPEnormalization with the shared lowercasing helperAWF_AUTH_PROVIDERnormalization in the credential pathFocused coverage
envAll-gated fallback toprocess.envExample of the shared lookup now used by both code paths: