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 provider adapter hand-builds validation/model/request auth headers, including static credentials, OIDC fallback, unavailable-token handling, and provider-specific extras.
Locations: containers/api-proxy/providers/openai.js, anthropic.js, copilot.js, and gemini.js.
Impact: More than two copies on the security-critical credential-injection path. The shared createProviderOidcAuth helper reduces setup duplication, but auth header construction and fallback semantics still remain scattered. This overlaps with the completed prior provider scaffolding finding [Duplicate Code] Provider adapter credential scaffolding is repeated across API proxy providers #5197, but the pattern still reproduces.
Evidence
OpenAI defines static header construction and OIDC/static fallback locally:
Add a small auth-header strategy abstraction, for example createAuthHeaderStrategy({ staticHeader, oidcHeader, extraHeaders, unavailableBehavior }), and let provider adapters supply only provider-specific constants and request predicates. Reuse it for validation headers, model fetch headers, and per-request headers so OIDC not-ready behavior and static-key fallback are implemented once.
Duplicate Code Opportunity
Summary
containers/api-proxy/providers/openai.js,anthropic.js,copilot.js, andgemini.js.createProviderOidcAuthhelper reduces setup duplication, but auth header construction and fallback semantics still remain scattered. This overlaps with the completed prior provider scaffolding finding [Duplicate Code] Provider adapter credential scaffolding is repeated across API proxy providers #5197, but the pattern still reproduces.Evidence
OpenAI defines static header construction and OIDC/static fallback locally:
Anthropic repeats OIDC readiness/static fallback for validation, model fetch, and request headers:
Copilot repeats request-path-specific auth prefix selection plus OIDC/static fallback:
Gemini is simpler but still hand-codes the same three surfaces for one credential header:
Suggested Refactoring
Add a small auth-header strategy abstraction, for example
createAuthHeaderStrategy({ staticHeader, oidcHeader, extraHeaders, unavailableBehavior }), and let provider adapters supply only provider-specific constants and request predicates. Reuse it for validation headers, model fetch headers, and per-request headers so OIDC not-ready behavior and static-key fallback are implemented once.Affected Files
containers/api-proxy/providers/openai.js— lines 75-114containers/api-proxy/providers/anthropic.js— lines 130-192containers/api-proxy/providers/copilot.js— lines 240-258containers/api-proxy/providers/gemini.js— lines 43-56Effort Estimate
Medium
Detected by Duplicate Code Detector workflow. Run date: 2026-06-27