Refactor provider unconfigured-response handling into adapter-factory metadata#5945
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors “provider not configured” (unconfigured) response handling in the API-proxy sidecar by centralizing request-time response construction in containers/api-proxy/adapter-factory.js. Providers (OpenAI, Anthropic, Copilot) now declare declarative response metadata instead of implementing bespoke getUnconfiguredResponse() functions.
Changes:
- Added declarative request-time response metadata (
missingCredentialResponse,unconfiguredResponseWhen) tobuildProviderAdapter()and centralized response construction viabuildUnconfiguredResponse(). - Updated OpenAI, Anthropic, and Copilot providers to remove duplicated
getUnconfiguredResponse()implementations and provide metadata instead. - Extended
adapter-factory.test.jsto cover auto-generation, override behavior, and validation errors for partial metadata.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/providers/openai.js | Replaces hand-built unconfigured response function with declarative metadata (preserving 404 vs 503 semantics). |
| containers/api-proxy/providers/anthropic.js | Moves request-time unconfigured response logic to adapter metadata while keeping OIDC “unavailable” behavior. |
| containers/api-proxy/providers/copilot.js | Converts unconfigured response generation to metadata, preserving structured provider_not_configured responses. |
| containers/api-proxy/adapter-factory.js | Adds centralized buildUnconfiguredResponse() and metadata-driven generation/validation in buildProviderAdapter(). |
| containers/api-proxy/adapter-factory.test.js | Adds factory-level tests for new declarative request-time response behavior. |
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: 0
- Review effort level: Low
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 98.81% | 98.81% | ➡️ +0.00% |
| Statements | 98.73% | 98.73% | ➡️ +0.00% |
| Functions | 99.58% | 99.58% | ➡️ +0.00% |
| Branches | 95.14% | 95.10% | 📉 -0.04% |
Coverage comparison generated by scripts/ci/compare-coverage.ts
|
✅ Smoke Gemini completed. All facets verified. 💎 Attempting to list PRs via MCP |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
✅ Contribution Check completed successfully! PR #5945 follows the applicable CONTRIBUTING.md guidelines based on the prefetched metadata, diff, and contribution guide; no comment needed. |
|
🔌 Smoke Services — All services reachable! ✅ |
|
✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓 |
|
Chroot tests failed Smoke Chroot failed - See logs for details. |
|
✅ Build Test Suite completed successfully! |
|
❌ Security Guard failed. Please review the logs for details. |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
✅ Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓 |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
✅ Smoke Claude passed |
Smoke Test: Copilot BYOK (Direct) Mode✅ GitHub MCP connectivity Status: PASS — Running in direct BYOK mode via COPILOT_PROVIDER_API_KEY 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.
|
|
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) 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: Services Connectivity
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.
|
Gemini Smoke Test Results
Overall status: FAIL (Pending MCP test) 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 Results
Overall: PASS Author: 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: 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: Copilot PAT Auth — PASS ✅
Overall: PASS | Auth mode: PAT (COPILOT_GITHUB_TOKEN) 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.
|
|
Merged PRs:
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: API Proxy OpenTelemetry Tracing
Result: All 5 scenarios pass. OTEL tracing 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.
|
|
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.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ 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.
|
OpenAI, Anthropic, and Copilot each hand-built request-time “unconfigured” responses with overlapping logic and slightly divergent semantics. This change centralizes that behavior in
adapter-factoryso providers declare response metadata instead of duplicating response builders.Adapter factory: declarative request-time response generation
buildProviderAdapter():missingCredentialResponseunconfiguredResponseWhenbuildUnconfiguredResponse()to produce either:{ error: string }payloads, orprovider_not_configuredpayloads (viamakeProviderNotConfiguredResponse).404missing-credential default vs503OIDC-unavailable override).Provider adapters: remove duplicated
getUnconfiguredResponse()implementationsopenai.js,anthropic.js,copilot.jsnow declare request-time response behavior through adapter metadata.Factory-level coverage for new behavior
adapter-factory.test.jsto cover:missingCredentialResponse,unconfiguredResponseWhen,