From f32588112e4ff563adc704d550d1821f8e63867f Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Sun, 29 Dec 2024 19:51:59 +0530 Subject: [PATCH] fix: resolved azure app config api not pulling all keys --- .../integration-auth/integration-sync-secret.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/src/services/integration-auth/integration-sync-secret.ts b/backend/src/services/integration-auth/integration-sync-secret.ts index 2d42f971b..912f1fafd 100644 --- a/backend/src/services/integration-auth/integration-sync-secret.ts +++ b/backend/src/services/integration-auth/integration-sync-secret.ts @@ -305,10 +305,16 @@ const syncSecretsAzureAppConfig = async ({ value: string; } - const getCompleteAzureAppConfigValues = async (url: string) => { + if (!integration.app || !integration.app.endsWith(".azconfig.io")) + throw new BadRequestError({ + message: "Invalid Azure App Configuration URL provided." + }); + + const getCompleteAzureAppConfigValues = async (baseURL: string, url: string) => { let result: AzureAppConfigKeyValue[] = []; while (url) { const res = await request.get(url, { + baseURL, headers: { Authorization: `Bearer ${accessToken}` }, @@ -319,7 +325,7 @@ const syncSecretsAzureAppConfig = async ({ }); result = result.concat(res.data.items); - url = res.data.nextLink; + url = res.data?.["@nextLink"]; } return result; @@ -327,11 +333,13 @@ const syncSecretsAzureAppConfig = async ({ const metadata = IntegrationMetadataSchema.parse(integration.metadata); - const azureAppConfigValuesUrl = `${integration.app}/kv?api-version=2023-11-01&key=${metadata.secretPrefix}*${ + const azureAppConfigValuesUrl = `/kv?api-version=2023-11-01&key=${metadata.secretPrefix}*${ metadata.azureLabel ? `&label=${metadata.azureLabel}` : "&label=%00" }`; - const azureAppConfigSecrets = (await getCompleteAzureAppConfigValues(azureAppConfigValuesUrl)).reduce( + const azureAppConfigSecrets = ( + await getCompleteAzureAppConfigValues(integration.app, azureAppConfigValuesUrl) + ).reduce( (accum, entry) => { accum[entry.key] = entry.value;