Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
sanitize github error
Thiago Araujo da Silvaa3348788e13f
diff --git a/backend/src/services/app-connection/github/github-connection-fns.ts b/backend/src/services/app-connection/github/github-connection-fns.tsindex bd8d779099..3f62b17409 100644--- a/backend/src/services/app-connection/github/github-connection-fns.ts+++ b/backend/src/services/app-connection/github/github-connection-fns.ts@@ -697,6 +697,23 @@ export function isGithubErrorResponse(data: GithubTokenRespData): data is Githubreturn "error" in data;}+export const sanitizeGitHubAxiosError = (error: unknown) => {+ if (error instanceof AxiosError) {+ const data = error.response?.data as { error?: string; error_description?: string; message?: string } | undefined;++ return {+ status: error.response?.status,+ code: error.code,+ githubError: data?.error,+ githubErrorDescription: data?.error_description,+ githubMessage: data?.message,+ message: error.message+ };+ }++ return { message: error instanceof Error ? error.message : "Unknown error" };+};+export type TGitHubUserInstallation = {id: number;app_id: number;@@ -898,7 +915,7 @@ export const validateGitHubConnectionCredentials = async (host: credentials.host};} catch (e: unknown) {- logger.error(e, "Unable to verify GitHub PAT connection");+ logger.error(sanitizeGitHubAxiosError(e), "Unable to verify GitHub PAT connection");throw new BadRequestError({message: "Unable to validate Personal Access Token: verify token has proper permissions"@@ -965,7 +982,7 @@ export const validateGitHubConnectionCredentials = async (});}} catch (e: unknown) {- logger.error(e, "Unable to verify GitHub connection");+ logger.error(sanitizeGitHubAxiosError(e), "Unable to verify GitHub connection");if (e instanceof BadRequestError) {throw e;diff --git a/backend/src/services/github-app/github-app-service.ts b/backend/src/services/github-app/github-app-service.tsindex ba7c20337e..49dae3ca22 100644--- a/backend/src/services/github-app/github-app-service.ts+++ b/backend/src/services/github-app/github-app-service.ts@@ -36,6 +36,7 @@ import {listGitHubUserInstallations,requestWithGitHubGateway,resolveGitHubAppCredentials,+ sanitizeGitHubAxiosError,signGitHubAppInstallationsToken,signGitHubAppJwt,TGitHubUserInstallation@@ -735,7 +736,10 @@ export const gitHubAppServiceFactory = ({});tokenData = data;} catch (err) {- logger.error(err, `Failed to exchange GitHub OAuth code [gitHubAppId=${gitHubAppId ?? "shared"}]`);+ logger.error(+ sanitizeGitHubAxiosError(err),+ `Failed to exchange GitHub OAuth code [gitHubAppId=${gitHubAppId ?? "shared"}]`+ );throw new BadRequestError({message: "Unable to authorize with GitHub. The code may be expired or invalid. Please try again."});