Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

address ai comments

adilson611d16cda80f
diff --git a/backend/src/ee/services/secret-rotation-v2/cloudflare-api-token/cloudflare-api-token-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/cloudflare-api-token/cloudflare-api-token-rotation-fns.ts
index c6618689cb..8a532f011e 100644
--- a/backend/src/ee/services/secret-rotation-v2/cloudflare-api-token/cloudflare-api-token-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/cloudflare-api-token/cloudflare-api-token-rotation-fns.ts
@@ -13,6 +13,7 @@ import {
TCloudflareTokenResources,
verifyCloudflareToken
} from "@app/ee/services/secret-rotation-v2/shared/cloudflare-token";
+import { BadRequestError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { CloudflareApiTokenPolicyScope } from "./cloudflare-api-token-rotation-schemas";
@@ -107,11 +108,14 @@ export const cloudflareApiTokenRotationFactory: TRotationFactory<
if (credentialsToRevoke?.tokenId) {
try {
await deleteCloudflareToken({ accountId, connectionApiToken, tokenId: credentialsToRevoke.tokenId });
- } catch (error) {
+ } catch (error: unknown) {
logger.error(
error,
- `cloudflareApiTokenRotation: failed to revoke previous token after rotation [rotationId=${rotationId}] [tokenId=${credentialsToRevoke.tokenId}]`
+ `Failed to revoke previous token after rotation [rotationId=${rotationId}] [tokenId=${credentialsToRevoke.tokenId}]`
);
+ throw new BadRequestError({
+ message: `Failed to revoke previous token after rotation [rotationId=${rotationId}] [tokenId=${credentialsToRevoke.tokenId}]`
+ });
}
}
diff --git a/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-fns.ts
index 03472cb927..644ae814a5 100644
--- a/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-fns.ts
@@ -161,8 +161,11 @@ export const cloudflareR2AccessKeyRotationFactory: TRotationFactory<
} catch (error) {
logger.error(
error,
- `cloudflareR2AccessKeyRotation: failed to revoke previous token after rotation [rotationId=${rotationId}] [tokenId=${credentialsToRevoke.accessKeyId}]`
+ `Failed to revoke previous token after rotation [rotationId=${rotationId}] [tokenId=${credentialsToRevoke.accessKeyId}]`
);
+ throw new BadRequestError({
+ message: `Failed to revoke previous token after rotation [rotationId=${rotationId}] [tokenId=${credentialsToRevoke.accessKeyId}]`
+ });
}
}
diff --git a/backend/src/services/app-connection/cloudflare/cloudflare-connection-fns.ts b/backend/src/services/app-connection/cloudflare/cloudflare-connection-fns.ts
index f8eb89ca18..d881a0fb83 100644
--- a/backend/src/services/app-connection/cloudflare/cloudflare-connection-fns.ts
+++ b/backend/src/services/app-connection/cloudflare/cloudflare-connection-fns.ts
@@ -36,6 +36,10 @@ export const getCloudflareErrorMessage = (error: unknown) => {
return (error.response?.data?.errors?.[0]?.message as string) || error.message || "Unknown error";
}
+ // every Cloudflare failure is reported through here, so a non-HTTP error (a safeRequest rejection, a
+ // programming error) must still say something diagnosable rather than collapsing to "Unknown error"
+ if (error instanceof Error) return error.message || "Unknown error";
+
return "Unknown error";
};
@@ -204,7 +208,9 @@ export const listCloudflareR2Buckets = async (appConnection: TCloudflareConnecti
return results.flatMap((result, index) => {
if (result.status === "fulfilled") return result.value;
- logger.error(
+ // an account without EU/FedRAMP enabled rejects those jurisdictions, so this is the expected path
+ // for most accounts on every call — not an error worth paging on
+ logger.debug(
result.reason,
`listCloudflareR2Buckets: skipping unavailable jurisdiction [jurisdiction=${jurisdictions[index]}]`
);
@@ -214,15 +220,12 @@ export const listCloudflareR2Buckets = async (appConnection: TCloudflareConnecti
};
export const validateCloudflareConnectionCredentials = async (config: TCloudflareConnectionConfig) => {
- const { apiToken, accountId } = config.credentials;
+ const { apiToken } = config.credentials;
try {
- const resp = await safeRequest.get(
- `${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/accounts/${accountId}/tokens/verify`,
- {
- headers: getCloudflareAuthHeaders(apiToken)
- }
- );
+ const resp = await safeRequest.get(`${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/user/tokens/verify`, {
+ headers: getCloudflareAuthHeaders(apiToken)
+ });
if (resp.data === null) {
throw new BadRequestError({