[Duplicate Code] Share OIDC unavailable-response scaffold across provider adapters
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
- Ambito
- api, authentication, backend, security
Direzione di ricerca
Review the repeated OIDC handling in containers/api-proxy/providers/openai.js, anthropic.js, and google-adapter.js, then inspect oidc-adapter-utils.js or adapter-factory.js for the appropriate shared-helper location. Confirm the requested-versus-configured behavior and provider-specific wording before extracting the response pair. Done means all three adapters use the shared logic while preserving retryability and matching unavailable health states.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Duplicate Code Opportunity
Summary
- Pattern: The provider adapters repeat the same OIDC failure-handling scaffold: compute an
oidcUnavailableError, return aprovider_not_configuredresponse when OIDC was requested but the token is unavailable, and expose a matchingunavailableWhenhealth state. - Locations:
containers/api-proxy/providers/openai.jslines 105-121;containers/api-proxy/providers/anthropic.jslines 180-203;containers/api-proxy/providers/google-adapter.jslines 86-124. - Impact: This is security-critical auth-path logic. A change to OIDC retryability, error wording, or the "requested vs configured" distinction must be kept in sync across multiple adapters.
Evidence
// containers/api-proxy/providers/openai.js:105-121
buildAdapterOptions: ({ oidcConfigured }) => ({
name: 'openai',
port: 10000,
isManagementPort: true,
bodyTransform: composedBodyTransform,
missingCredentialResponse: {
kind: 'plain_error',
statusCode: 404,
message: 'OpenAI proxy not configured (no OPENAI_API_KEY/COPILOT_PROVIDER_API_KEY or OIDC auth)',
},
unconfiguredResponseWhen: () => (oidcConfigured
? {
kind: 'provider_not_configured',
message: 'OpenAI OIDC token unavailable; retry shortly',
retryable: true,
}
: null),
extra: {
participatesInValidation: true,
_hostedWebPolicy: hostedWebPolicy,
},
}),
// containers/api-proxy/providers/anthropic.js:180-203
buildAdapterOptions: ({ oidcConfigured }) => {
const oidcUnavailableError = oidcConfigured
? 'Anthropic OIDC token unavailable; retry shortly'
: 'Anthropic OIDC requires ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN (permissions: id-token: write).';
return {
name: 'anthropic',
port: 10001,
isManagementPort: false,
bodyTransform: composedBodyTransform,
missingCredentialResponse: {
kind: 'provider_not_configured',
message: 'Credentials for Anthropic (port 10001) are not configured. Set ANTHROPIC_API_KEY to enable this provider.',
},
unconfiguredResponseWhen: () => (oidcRequested
? {
kind: 'provider_not_configured',
message: oidcUnavailableError,
retryable: oidcConfigured,
}
: null),
healthServiceName: 'awf-api-proxy-anthropic',
missingCredentialMessage: 'ANTHROPIC_API_KEY not configured in api-proxy sidecar',
unavailableWhen: () => oidcRequested ? { message: oidcUnavailableError, status: 'unavailable' } : null,
};
},
Suggested Refactoring
Extract a small helper in oidc-adapter-utils.js or adapter-factory.js that builds the OIDC unavailable response pair from { provider, requested, configured, unavailableMessage }. That helper should return the retryable provider_not_configured payload and the matching health-state object so adapters only supply provider-specific wording.
Affected Files
containers/api-proxy/providers/openai.js— lines 105-121containers/api-proxy/providers/anthropic.js— lines 180-203containers/api-proxy/providers/google-adapter.js— lines 86-124
Effort Estimate
Low
Detected by Duplicate Code Detector workflow. Run date: 2026-09-25
Generated by Duplicate Code Detector · copilot · gpt50mini · 14.2 AIC · ⊞ 21K · ◷
- expires on Oct 25, 2026, 9:45 PM UTC
- Lingua principale
- TypeScript
- Stelle
- 150
- Fork
- 76
- Merge medio
- 3h 29m
- PR unite (30g)
- 451
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/gh-aw-firewall
-
agentic-workflows automated dependencies
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/gh-aw-firewall#3837 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows
Difficoltà 4/5 1-2 giorni Idoneità per principianti 35/100
github/gh-aw-firewall#10684 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
github/gh-aw-firewall#10683 ·
I maintainer di solito rispondono entro 1 giorno
-
Unify model-name resolution with canonical provider-qualified catalogue identitiesForse già presa @lpcox l’ha presa 1 giorno fa. Aperta
github/gh-aw-firewall#10670 · 1 reazione · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
github/gh-aw-firewall#10668 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di github/gh-aw-firewall
Issue simili
-
category::task code priority::normal
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
e0ipso/strikethroo#145 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
cocos/cocos-docs#3333 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
RevenueCat/react-native-purchases#2079 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
RevenueCat/purchases-hybrid-common#2039 ·
I maintainer di solito rispondono entro 1 giorno
-
agent-reported area/react bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno