Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions containers/api-proxy/providers/anthropic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
const {
composeBodyTransforms,
makeProviderNotConfiguredResponse,
makeUnconfiguredHealthResponse,
validateAuthHeaderEnv,
createBaseAdapterConfig,
createAdapterMethods,
Expand Down Expand Up @@ -229,15 +230,9 @@ function createAnthropicAdapter(env, deps = {}) {
/** /health response when not configured. */
getUnconfiguredHealthResponse() {
if (oidcRequested) {
return {
statusCode: 503,
body: { status: 'unavailable', service: 'awf-api-proxy-anthropic', error: oidcUnavailableError },
};
return makeUnconfiguredHealthResponse('awf-api-proxy-anthropic', oidcUnavailableError, 'unavailable');
}
return {
statusCode: 503,
body: { status: 'not_configured', service: 'awf-api-proxy-anthropic', error: 'ANTHROPIC_API_KEY not configured in api-proxy sidecar' },
};
return makeUnconfiguredHealthResponse('awf-api-proxy-anthropic', 'ANTHROPIC_API_KEY not configured in api-proxy sidecar');
},

// Exposed for introspection (logging, tests)
Expand Down
11 changes: 3 additions & 8 deletions containers/api-proxy/providers/copilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
const {
normalizeBasePath,
makeProviderNotConfiguredResponse,
makeUnconfiguredHealthResponse,
createAdapterMethods,
composeBodyTransforms,
} = require('../proxy-utils');
Expand Down Expand Up @@ -305,15 +306,9 @@ function createCopilotAdapter(env, deps = {}) {
/** /health response when not configured. */
getUnconfiguredHealthResponse() {
if (oidcConfigured) {
return {
statusCode: 503,
body: { status: 'not_configured', service: 'awf-api-proxy-copilot', error: `Copilot OIDC token (${authProvider}) not yet available in api-proxy sidecar` },
};
return makeUnconfiguredHealthResponse('awf-api-proxy-copilot', `Copilot OIDC token (${authProvider}) not yet available in api-proxy sidecar`);
}
return {
statusCode: 503,
body: { status: 'not_configured', service: 'awf-api-proxy-copilot', error: 'COPILOT_GITHUB_TOKEN or COPILOT_PROVIDER_API_KEY not configured in api-proxy sidecar' },
};
return makeUnconfiguredHealthResponse('awf-api-proxy-copilot', 'COPILOT_GITHUB_TOKEN or COPILOT_PROVIDER_API_KEY not configured in api-proxy sidecar');
},

// Exposed for introspection / testing
Expand Down
7 changes: 2 additions & 5 deletions containers/api-proxy/providers/gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Gemini SDK versions append alongside the header.
*/

const { stripGeminiKeyParam, createBaseAdapterConfig, createAdapterMethods } = require('../proxy-utils');
const { stripGeminiKeyParam, createBaseAdapterConfig, createAdapterMethods, makeUnconfiguredHealthResponse } = require('../proxy-utils');

/**
* Create the Google Gemini provider adapter.
Expand Down Expand Up @@ -90,10 +90,7 @@ function createGeminiAdapter(env, deps = {}) {

/** /health response when not configured. */
getUnconfiguredHealthResponse() {
return {
statusCode: 503,
body: { status: 'not_configured', service: 'awf-api-proxy-gemini', error: 'GEMINI_API_KEY not configured in api-proxy sidecar' },
};
return makeUnconfiguredHealthResponse('awf-api-proxy-gemini', 'GEMINI_API_KEY not configured in api-proxy sidecar');
},
};
}
Expand Down
11 changes: 11 additions & 0 deletions containers/api-proxy/proxy-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ function makeProviderNotConfiguredResponse(provider, port, message) {
};
}

/**
* Build the standard health-endpoint response for an unconfigured provider.
* @param {string} service - Service identifier (e.g. 'awf-api-proxy-anthropic')
* @param {string} error - Human-readable error message
* @param {string} [status='not_configured'] - Status string ('not_configured' or 'unavailable')
*/
function makeUnconfiguredHealthResponse(service, error, status = 'not_configured') {
return { statusCode: 503, body: { status, service, error } };
Comment on lines +222 to +226
}

/**
* Validate that a string is a legal HTTP header name.
* @param {string} name - The header name to validate
Expand Down Expand Up @@ -392,6 +402,7 @@ module.exports = {
shouldStripHeader,
composeBodyTransforms,
makeProviderNotConfiguredResponse,
makeUnconfiguredHealthResponse,
isValidHeaderName,
validateAuthHeaderEnv,
createBaseAdapterConfig,
Expand Down
Loading