You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pattern: Each API proxy adapter declares a small getUnconfiguredHealthResponse() wrapper that differs only by service name, env-var message, and optional OIDC unavailable branch.
/** /health response when not configured. */getUnconfiguredHealthResponse(){if(oidcRequested){returnmakeUnconfiguredHealthResponse('awf-api-proxy-anthropic',oidcUnavailableError,'unavailable');}returnmakeUnconfiguredHealthResponse('awf-api-proxy-anthropic','ANTHROPIC_API_KEY not configured in api-proxy sidecar');},
/** /health response when not configured. */getUnconfiguredHealthResponse(){if(oidcConfigured){returnmakeUnconfiguredHealthResponse('awf-api-proxy-copilot',`Copilot OIDC token (${authProvider}) not yet available in api-proxy sidecar`);}returnmakeUnconfiguredHealthResponse('awf-api-proxy-copilot','COPILOT_GITHUB_TOKEN or COPILOT_PROVIDER_API_KEY not configured in api-proxy sidecar');},
/** /health response when not configured. */getUnconfiguredHealthResponse(){returnmakeUnconfiguredHealthResponse('awf-api-proxy-gemini','GEMINI_API_KEY not configured in api-proxy sidecar');},
/** /health response when not configured. */getUnconfiguredHealthResponse(){returnmakeUnconfiguredHealthResponse('awf-api-proxy-vertex','GOOGLE_API_KEY not configured in api-proxy sidecar');},
Suggested Refactoring
Move the default health-response construction into buildProviderAdapter or a provider metadata helper. Let adapters pass static metadata such as healthServiceName, missingCredentialMessage, and optionally an unavailableWhen/unavailableMessage callback for OIDC. That would keep provider-specific wording close to configuration while eliminating repeated imperative wrappers.
Duplicate Code Opportunity
Summary
getUnconfiguredHealthResponse()wrapper that differs only by service name, env-var message, and optional OIDC unavailable branch.containers/api-proxy/providers/anthropic.jslines 225-231,containers/api-proxy/providers/copilot.jslines 265-271,containers/api-proxy/providers/gemini.jslines 78-81, andcontainers/api-proxy/providers/vertex.jslines 70-73.getUnconfiguredHealthResponsebody structure duplicated across three provider adapters #4635 in current code. Score: >20 duplicate lines (+3), more than 2 copies (+2), easy extraction (+1) = 6.Evidence
containers/api-proxy/providers/anthropic.jslines 225-231:containers/api-proxy/providers/copilot.jslines 265-271:containers/api-proxy/providers/gemini.jslines 78-81:containers/api-proxy/providers/vertex.jslines 70-73:Suggested Refactoring
Move the default health-response construction into
buildProviderAdapteror a provider metadata helper. Let adapters pass static metadata such ashealthServiceName,missingCredentialMessage, and optionally anunavailableWhen/unavailableMessagecallback for OIDC. That would keep provider-specific wording close to configuration while eliminating repeated imperative wrappers.Affected Files
containers/api-proxy/providers/anthropic.js— lines 225-231containers/api-proxy/providers/copilot.js— lines 265-271containers/api-proxy/providers/gemini.js— lines 78-81containers/api-proxy/providers/vertex.js— lines 70-73Effort Estimate
Low
Detected by Duplicate Code Detector workflow. Run date: 2026-07-05
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpgSee Network Configuration for more information.