Skip to content

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

fix greptile comments

Matheus Nogueira7b45fc706f22
diff --git a/backend/src/services/app-connection/netlify/netlify-connection-public-client.ts b/backend/src/services/app-connection/netlify/netlify-connection-public-client.ts
index d1328539b4..04b9fe8c19 100644
--- a/backend/src/services/app-connection/netlify/netlify-connection-public-client.ts
+++ b/backend/src/services/app-connection/netlify/netlify-connection-public-client.ts
@@ -94,23 +94,30 @@ class NetlifyPublicClient {
}
}
- async getVariables(
- connection: TNetlifyConnectionConfig,
- { account_id, ...params }: NetlifyParams,
- limit: number = 50,
- page: number = 1
- ) {
- const res = await this.send<TNetlifyVariable[]>(connection, {
- method: "GET",
- url: `/accounts/${account_id}/env`,
- params: {
- ...params,
- limit,
- page
- }
- });
+ async getVariables(connection: TNetlifyConnectionConfig, { account_id, ...params }: NetlifyParams) {
+ const PAGE_SIZE = 100;
+ const allVariables: TNetlifyVariable[] = [];
+ let page = 1;
+
+ // eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
+ while (true) {
+ const res = await this.send<TNetlifyVariable[]>(connection, {
+ method: "GET",
+ url: `/accounts/${account_id}/env`,
+ params: {
+ ...params,
+ limit: PAGE_SIZE,
+ page
+ }
+ });
- return res;
+ allVariables.push(...res);
+
+ if (res.length < PAGE_SIZE) break;
+ page += 1;
+ }
+
+ return allVariables;
}
async createVariable(
diff --git a/backend/src/services/secret-sync/netlify/netlify-sync-fns.ts b/backend/src/services/secret-sync/netlify/netlify-sync-fns.ts
index efedd9a5f2..cee61dffd9 100644
--- a/backend/src/services/secret-sync/netlify/netlify-sync-fns.ts
+++ b/backend/src/services/secret-sync/netlify/netlify-sync-fns.ts
@@ -44,11 +44,11 @@ export const NetlifySyncFns = {
const baseParams = {
account_id: config.accountId,
site_id: config.siteId
- }
+ };
const params = {
...baseParams,
- context_name: config.context,
+ context_name: config.context
};
const variables = await NetlifyPublicAPI.getVariables(secretSync.connection, baseParams);
@@ -87,11 +87,9 @@ export const NetlifySyncFns = {
await NetlifyPublicAPI.createVariable(secretSync.connection, params, {
key,
is_secret: false,
- // We don't merge existing values from other contexts here because secrets are returned with
+ // We don't merge existing values from other contexts here because secrets are returned with
// masked values. So it would be replaced as *******
- values: [
- { context: config.context, value: secretMap[key].value }
- ]
+ values: [{ context: config.context, value: secretMap[key].value }]
});
} else {
const mergedValues = [
@@ -114,7 +112,9 @@ export const NetlifySyncFns = {
const variable = existingInNetlify[key];
const remainingValues = variable.values.filter((v) => v.context !== config.context);
- if (remainingValues.length > 0) {
+ // We skip updating variables in case of `is_secret`, otherwise we override the
+ // correct value with a masked one.
+ if (remainingValues.length > 0 && !variable.is_secret) {
await NetlifyPublicAPI.updateVariable(secretSync.connection, params, {
key,
values: remainingValues
@@ -151,7 +151,9 @@ export const NetlifySyncFns = {
const variable = existingSecrets[secret];
const remainingValues = variable.values.filter((v) => v.context !== config.context);
- if (remainingValues.length > 0) {
+ // We skip updating variables in case of `is_secret`, otherwise we override the
+ // correct value with a masked one.
+ if (remainingValues.length > 0 && !variable.is_secret) {
await NetlifyPublicAPI.updateVariable(secretSync.connection, params, {
key: secret,
values: remainingValues