From 6c6c4db92cd3ca1669d1588c30b9f71e3f8139c0 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Thu, 17 Apr 2025 12:20:02 -0700 Subject: [PATCH 1/2] fix: use a non-team based api call for validation --- .../vercel/vercel-connection-fns.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/backend/src/services/app-connection/vercel/vercel-connection-fns.ts b/backend/src/services/app-connection/vercel/vercel-connection-fns.ts index 43de8641d..6b8c618f3 100644 --- a/backend/src/services/app-connection/vercel/vercel-connection-fns.ts +++ b/backend/src/services/app-connection/vercel/vercel-connection-fns.ts @@ -1,5 +1,5 @@ /* eslint-disable no-await-in-loop */ -import { AxiosError, AxiosResponse } from "axios"; +import { AxiosError } from "axios"; import { request } from "@app/lib/config/request"; import { BadRequestError, InternalServerError } from "@app/lib/errors"; @@ -27,10 +27,8 @@ export const getVercelConnectionListItem = () => { export const validateVercelConnectionCredentials = async (config: TVercelConnectionConfig) => { const { credentials: inputCredentials } = config; - let response: AxiosResponse | null = null; - try { - response = await request.get(`${IntegrationUrls.VERCEL_API_URL}/v9/projects`, { + await request.get(`${IntegrationUrls.VERCEL_API_URL}/v2/user`, { headers: { Authorization: `Bearer ${inputCredentials.apiToken}` } @@ -38,17 +36,14 @@ export const validateVercelConnectionCredentials = async (config: TVercelConnect } catch (error: unknown) { if (error instanceof AxiosError) { throw new BadRequestError({ - message: `Failed to validate credentials: ${error.message || "Unknown error"}` + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + message: `Failed to validate credentials: ${ + error.response?.data ? JSON.stringify(error.response?.data) : error.message || "Unknown error" + }` }); } throw new BadRequestError({ - message: "Unable to validate connection - verify credentials" - }); - } - - if (!response?.data) { - throw new InternalServerError({ - message: "Failed to get organizations: Response was empty" + message: `Unable to validate connection: ${(error as Error).message || "Verify credentials"}` }); } From 7655dc7f3c02fae7285cd495d03a6935caf97b50 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Thu, 17 Apr 2025 12:22:02 -0700 Subject: [PATCH 2/2] chore: remove unused type --- .../src/services/app-connection/vercel/vercel-connection-fns.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/services/app-connection/vercel/vercel-connection-fns.ts b/backend/src/services/app-connection/vercel/vercel-connection-fns.ts index 6b8c618f3..01eac84dc 100644 --- a/backend/src/services/app-connection/vercel/vercel-connection-fns.ts +++ b/backend/src/services/app-connection/vercel/vercel-connection-fns.ts @@ -28,7 +28,7 @@ export const validateVercelConnectionCredentials = async (config: TVercelConnect const { credentials: inputCredentials } = config; try { - await request.get(`${IntegrationUrls.VERCEL_API_URL}/v2/user`, { + await request.get(`${IntegrationUrls.VERCEL_API_URL}/v2/user`, { headers: { Authorization: `Bearer ${inputCredentials.apiToken}` }