Skip to content

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

refactor(secret-sync): rename the recursive option to includeAllSubFolders

Calvin94418f8e13a7
diff --git a/backend/e2e-test/routes/v1/secret-sync-recursive.spec.ts b/backend/e2e-test/routes/v1/secret-sync-recursive.spec.ts
index 2192e61517..ad1d8869d9 100644
--- a/backend/e2e-test/routes/v1/secret-sync-recursive.spec.ts
+++ b/backend/e2e-test/routes/v1/secret-sync-recursive.spec.ts
@@ -43,7 +43,7 @@ describe("A secret sync is refused when it would read a folder the actor cannot"
let connectionId: string;
let actorToken: string;
- const newSync = (dto: { name: string; recursive: boolean; expectStatusCode?: number }) =>
+ const newSync = (dto: { name: string; includeAllSubFolders: boolean; expectStatusCode?: number }) =>
createSecretSync({
name: dto.name,
projectId,
@@ -53,7 +53,7 @@ describe("A secret sync is refused when it would read a folder the actor cannot"
region: REGION,
destinationPath: `/${dto.name}/`,
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: dto.recursive,
+ includeAllSubFolders: dto.includeAllSubFolders,
isAutoSyncEnabled: false,
authToken: actorToken,
expectStatusCode: dto.expectStatusCode
@@ -129,7 +129,7 @@ describe("A secret sync is refused when it would read a folder the actor cannot"
});
test("creating a sync that includes subfolders is refused, naming the folder that is denied", async () => {
- const { error } = await newSync({ name: "recursive-denied", recursive: true, expectStatusCode: 403 });
+ const { error } = await newSync({ name: "recursive-denied", includeAllSubFolders: true, expectStatusCode: 403 });
expect(error.message).toContain("/backend/api");
});
@@ -148,7 +148,7 @@ describe("A secret sync is refused when it would read a folder the actor cannot"
region: REGION,
destinationPath: "/recursive-created-by-admin/",
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: true,
+ includeAllSubFolders: true,
isAutoSyncEnabled: false,
authToken: adminToken
});
@@ -164,14 +164,14 @@ describe("A secret sync is refused when it would read a folder the actor cannot"
});
test("turning subfolders on for an existing sync is refused", async () => {
- const { secretSync } = await newSync({ name: "recursive-turned-on-later", recursive: false });
+ const { secretSync } = await newSync({ name: "recursive-turned-on-later", includeAllSubFolders: false });
const { error } = await updateSecretSync({
syncId: secretSync!.id,
body: {
syncOptions: {
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: true
+ includeAllSubFolders: true
}
},
authToken: actorToken,
@@ -194,7 +194,7 @@ describe("A recursive secret sync is refused when two folders use the same secre
let cleanupOrg: () => Promise<void>;
let connectionId: string;
- const newSync = (dto: { name: string; recursive: boolean; expectStatusCode?: number }) =>
+ const newSync = (dto: { name: string; includeAllSubFolders: boolean; expectStatusCode?: number }) =>
createSecretSync({
name: dto.name,
projectId,
@@ -204,7 +204,7 @@ describe("A recursive secret sync is refused when two folders use the same secre
region: REGION,
destinationPath: `/${dto.name}/`,
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: dto.recursive,
+ includeAllSubFolders: dto.includeAllSubFolders,
isAutoSyncEnabled: false,
authToken: adminToken,
expectStatusCode: dto.expectStatusCode
@@ -237,7 +237,7 @@ describe("A recursive secret sync is refused when two folders use the same secre
region: REGION,
destinationPath: `/${dto.name}/`,
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: true,
+ includeAllSubFolders: true,
isAutoSyncEnabled: false,
authToken: adminToken
});
@@ -303,7 +303,7 @@ describe("A recursive secret sync is refused when two folders use the same secre
});
test("creating it is refused, naming the secret and both folders", async () => {
- const { error } = await newSync({ name: "recursive-duplicate", recursive: true, expectStatusCode: 400 });
+ const { error } = await newSync({ name: "recursive-duplicate", includeAllSubFolders: true, expectStatusCode: 400 });
expect(error.message).toContain("DB_URL");
expect(error.message).toContain("/backend");
@@ -335,7 +335,7 @@ describe("A recursive secret sync is refused when two folders use the same secre
const updated = await getSecretSync({ syncId: secretSync.id, authToken: adminToken });
- expect(updated.syncOptions.recursive).toBeFalsy();
+ expect(updated.syncOptions.includeAllSubFolders).toBeFalsy();
});
test("an update that leaves the sync options alone is still checked as recursive", async () => {
@@ -357,14 +357,14 @@ describe("A recursive secret sync is refused when two folders use the same secre
});
test("turning subfolders on for an existing sync is refused", async () => {
- const { secretSync } = await newSync({ name: "recursive-turned-on-later", recursive: false });
+ const { secretSync } = await newSync({ name: "recursive-turned-on-later", includeAllSubFolders: false });
const { error } = await updateSecretSync({
syncId: secretSync!.id,
body: {
syncOptions: {
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: true
+ includeAllSubFolders: true
}
},
authToken: adminToken,
@@ -434,7 +434,7 @@ describe("A change in a subfolder reaches the recursive sync above it", async ()
region: REGION,
destinationPath,
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: true,
+ includeAllSubFolders: true,
isAutoSyncEnabled: false,
authToken: adminToken
});
@@ -506,7 +506,7 @@ describe("A change in a subfolder reaches the recursive sync above it", async ()
region: REGION,
destinationPath,
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: true,
+ includeAllSubFolders: true,
isAutoSyncEnabled: false,
authToken: adminToken
});
@@ -541,7 +541,9 @@ describe("A change in a subfolder reaches the recursive sync above it", async ()
});
// A run that starts after the delete, not merely an empty destination: only the delete can have
- // queued it.
+ // queued it. waitForSyncRun returns once the run has started and the record reports a terminal
+ // status, which the previous run already satisfies, so the destination is read by polling rather
+ // than immediately.
await waitForSyncRun({
syncId: secretSync!.id,
region: REGION,
@@ -550,6 +552,6 @@ describe("A change in a subfolder reaches the recursive sync above it", async ()
authToken: adminToken
});
- expect(fakeParameterStore.at(REGION, destinationPath).read()).toEqual({});
+ await waitForDestinationSecrets({ region: REGION, destinationPath, expected: {} });
});
});
diff --git a/backend/e2e-test/testUtils/secret-syncs.ts b/backend/e2e-test/testUtils/secret-syncs.ts
index e9d59713e6..41efed11a6 100644
--- a/backend/e2e-test/testUtils/secret-syncs.ts
+++ b/backend/e2e-test/testUtils/secret-syncs.ts
@@ -15,7 +15,7 @@ type TSecretSyncRecord = {
name: string;
syncOptions: {
initialSyncBehavior: string;
- recursive?: boolean;
+ includeAllSubFolders?: boolean;
keySchema?: string;
disableSecretDeletion?: boolean;
};
@@ -72,7 +72,7 @@ export const createSecretSync = async (dto: {
initialSyncBehavior?: SecretSyncInitialSyncBehavior;
keySchema?: string;
disableSecretDeletion?: boolean;
- recursive?: boolean;
+ includeAllSubFolders?: boolean;
isAutoSyncEnabled?: boolean;
authToken: string;
expectStatusCode?: number;
@@ -92,7 +92,7 @@ export const createSecretSync = async (dto: {
initialSyncBehavior: dto.initialSyncBehavior ?? SecretSyncInitialSyncBehavior.OverwriteDestination,
...(dto.keySchema ? { keySchema: dto.keySchema } : {}),
...(dto.disableSecretDeletion === undefined ? {} : { disableSecretDeletion: dto.disableSecretDeletion }),
- ...(dto.recursive === undefined ? {} : { recursive: dto.recursive })
+ ...(dto.includeAllSubFolders === undefined ? {} : { includeAllSubFolders: dto.includeAllSubFolders })
},
destinationConfig: { region: dto.region, path: dto.destinationPath }
}
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 1871dd86d0..bc9e823c94 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -3145,7 +3145,7 @@ export const SecretSyncs = {
initialSyncBehavior: `Specify how Infisical should resolve the initial sync to the ${destinationName} destination.`,
keySchema: `Specify the format to use for structuring secret keys in the ${destinationName} destination.`,
disableSecretDeletion: `Enable this flag to prevent removal of secrets from the ${destinationName} destination when syncing.`,
- recursive: `Whether to sync secrets from folders beneath the source path as well.`
+ includeAllSubFolders: `Whether to sync secrets from folders beneath the source path as well.`
};
},
ADDITIONAL_SYNC_OPTIONS: {
diff --git a/backend/src/services/secret-sync/secret-sync-queue.ts b/backend/src/services/secret-sync/secret-sync-queue.ts
index a4f9afa8e2..e8cf779382 100644
--- a/backend/src/services/secret-sync/secret-sync-queue.ts
+++ b/backend/src/services/secret-sync/secret-sync-queue.ts
@@ -432,7 +432,7 @@ export const secretSyncQueueFactory = ({
const importedSecretMap: TSecretMap = {};
- // Import behavior is never combined with a recursive sync, so this payload always covers
+ // Import behavior is never combined with including subfolders, so this payload always covers
// exactly one folder. Comparison is against raw keys as returned by the destination
// (already schema-stripped), so entries come from `secrets` rather than the schema-applying flatten().
const payload = await $getInfisicalSecrets(secretSync, false);
@@ -1067,12 +1067,13 @@ export const secretSyncQueueFactory = ({
isAutoSyncEnabled: true
});
- // A sync on the path itself always matches, recursive or not. A sync on an ancestor folder only
- // matches when it is recursive, so a non-recursive sync rooted above this path is never
- // triggered by a change it was never configured to cover.
+ // A sync on the path itself always matches, whether or not it includes subfolders. A sync on an
+ // ancestor folder only matches when it includes them, so a sync rooted above this path that does
+ // not is never triggered by a change it was never configured to cover.
const secretSyncs = candidateSyncs.filter(
(sync) =>
- (folder && sync.folderId === folder.id) || Boolean((sync.syncOptions as TSecretSync["syncOptions"])?.recursive)
+ (folder && sync.folderId === folder.id) ||
+ Boolean((sync.syncOptions as TSecretSync["syncOptions"])?.includeAllSubFolders)
);
await secretSyncDAL.update(
diff --git a/backend/src/services/secret-sync/secret-sync-recursive-fns.test.ts b/backend/src/services/secret-sync/secret-sync-recursive-fns.test.ts
index 13472e73b9..6ef305a268 100644
--- a/backend/src/services/secret-sync/secret-sync-recursive-fns.test.ts
+++ b/backend/src/services/secret-sync/secret-sync-recursive-fns.test.ts
@@ -16,27 +16,27 @@ const deps = {
} as unknown as Pick<Parameters<typeof getSyncedFolders>[0], "folderDAL" | "projectEnvDAL">;
describe("getSyncedFolders", () => {
- test("returns only the source folder when recursive is off", async () => {
+ test("returns only the source folder when subfolders are off", async () => {
const folders = await getSyncedFolders({
...deps,
projectId: "proj-1",
environment: "dev",
sourcePath: "/",
sourceFolderId: "root",
- recursive: false
+ includeAllSubFolders: false
});
expect(folders).toEqual([{ folderId: "root", path: "/" }]);
});
- test("returns the source folder and its descendants when recursive is on", async () => {
+ test("returns the source folder and its descendants when subfolders are on", async () => {
const folders = await getSyncedFolders({
...deps,
projectId: "proj-1",
environment: "dev",
sourcePath: "/",
sourceFolderId: "root",
- recursive: true
+ includeAllSubFolders: true
});
expect(folders.map((folder) => folder.path).sort()).toEqual(["/", "/api"]);
@@ -226,7 +226,7 @@ describe("buildSyncPayload", () => {
environment: "dev",
sourcePath: "/",
sourceFolderId: "root",
- syncOptions: { recursive: true },
+ syncOptions: { includeAllSubFolders: true },
includeImports: true
},
buildDeps
@@ -285,7 +285,7 @@ describe("buildSyncPayload cross-folder duplicates", () => {
environment: "dev",
sourcePath: "/",
sourceFolderId: "root",
- syncOptions: { recursive: true },
+ syncOptions: { includeAllSubFolders: true },
includeImports: true
} as Parameters<typeof buildSyncPayload>[0];
diff --git a/backend/src/services/secret-sync/secret-sync-recursive-fns.ts b/backend/src/services/secret-sync/secret-sync-recursive-fns.ts
index c7c112e499..7fe27f10e7 100644
--- a/backend/src/services/secret-sync/secret-sync-recursive-fns.ts
+++ b/backend/src/services/secret-sync/secret-sync-recursive-fns.ts
@@ -41,7 +41,7 @@ export const getSyncedFolders = async ({
environment,
sourcePath,
sourceFolderId,
- recursive
+ includeAllSubFolders
}: {
folderDAL: Pick<TSecretFolderDALFactory, "find">;
projectEnvDAL: Pick<TProjectEnvDALFactory, "findOne">;
@@ -49,9 +49,9 @@ export const getSyncedFolders = async ({
environment: string;
sourcePath: string;
sourceFolderId: string;
- recursive: boolean;
+ includeAllSubFolders: boolean;
}): Promise<{ folderId: string; path: string }[]> => {
- if (!recursive) return [{ folderId: sourceFolderId, path: sourcePath }];
+ if (!includeAllSubFolders) return [{ folderId: sourceFolderId, path: sourcePath }];
const paths = await recursivelyGetSecretPaths({
folderDAL,
@@ -99,8 +99,8 @@ export const mergeImportedSecrets = (
return merged;
};
-// Resolves and decrypts every secret in the sync's source subtree (a single folder, or, when
-// recursive, that folder plus every folder beneath it), merging in any imports, and wraps the
+// Resolves and decrypts every secret in the sync's source subtree (a single folder, or, when the
+// sync includes subfolders, that folder plus every folder beneath it), merging in any imports, and wraps the
// result in a TSecretSyncPayload. A cross-folder duplicate name is not resolved here: flatten()
// throws on it by default, and payload.dedupeConflicts() is how the one caller that needs to
// tolerate it (removal) gets a payload that won't.
@@ -110,7 +110,7 @@ export const buildSyncPayload = async (
environment: string;
sourcePath: string;
sourceFolderId: string;
- syncOptions: Pick<TSecretSync["syncOptions"], "recursive" | "keySchema"> | undefined;
+ syncOptions: Pick<TSecretSync["syncOptions"], "includeAllSubFolders" | "keySchema"> | undefined;
includeImports: boolean;
},
deps: {
@@ -126,7 +126,7 @@ export const buildSyncPayload = async (
const { folderDAL, projectEnvDAL, secretV2BridgeDAL, secretImportDAL, expandSecretReferences, decryptSecretValue } =
deps;
const { projectId, environment, sourcePath, sourceFolderId, syncOptions, includeImports } = args;
- const { recursive, keySchema } = syncOptions ?? {};
+ const { includeAllSubFolders, keySchema } = syncOptions ?? {};
const folders = await getSyncedFolders({
folderDAL,
@@ -135,7 +135,7 @@ export const buildSyncPayload = async (
environment,
sourcePath,
sourceFolderId,
- recursive: Boolean(recursive)
+ includeAllSubFolders: Boolean(includeAllSubFolders)
});
const pathByFolderId = new Map(folders.map(({ folderId, path }) => [folderId, path]));
diff --git a/backend/src/services/secret-sync/secret-sync-schemas.test.ts b/backend/src/services/secret-sync/secret-sync-schemas.test.ts
index d8bb0a67f1..640441e949 100644
--- a/backend/src/services/secret-sync/secret-sync-schemas.test.ts
+++ b/backend/src/services/secret-sync/secret-sync-schemas.test.ts
@@ -3,28 +3,28 @@ import { BaseSecretSyncSchema, KeySchemaSchema } from "./secret-sync-schemas";
const schema = BaseSecretSyncSchema(SecretSync.Render, { canImportSecrets: true }).shape.syncOptions;
-describe("BaseSyncOptionsSchema recursive", () => {
- test("defaults to absent, which means non-recursive", () => {
+describe("BaseSyncOptionsSchema includeAllSubFolders", () => {
+ test("defaults to absent, which means the source folder only", () => {
const result = schema.safeParse({ initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination });
expect(result.success).toBe(true);
- expect(result.success && result.data.recursive).toBeUndefined();
+ expect(result.success && result.data.includeAllSubFolders).toBeUndefined();
});
- test("accepts recursive with the overwrite behavior", () => {
+ test("accepts including subfolders with the overwrite behavior", () => {
const result = schema.safeParse({
initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination,
- recursive: true
+ includeAllSubFolders: true
});
expect(result.success).toBe(true);
});
// See RECURSIVE_SYNC_REFINEMENT.
- test("rejects recursive combined with importing from the destination", () => {
+ test("rejects including subfolders combined with importing from the destination", () => {
const result = schema.safeParse({
initialSyncBehavior: SecretSyncInitialSyncBehavior.ImportPrioritizeSource,
- recursive: true
+ includeAllSubFolders: true
});
expect(result.success).toBe(false);
diff --git a/backend/src/services/secret-sync/secret-sync-schemas.ts b/backend/src/services/secret-sync/secret-sync-schemas.ts
index 782f304501..5e1681c8a2 100644
--- a/backend/src/services/secret-sync/secret-sync-schemas.ts
+++ b/backend/src/services/secret-sync/secret-sync-schemas.ts
@@ -9,16 +9,16 @@ import { SecretSync, SecretSyncInitialSyncBehavior } from "@app/services/secret-
import { SECRET_SYNC_CONNECTION_MAP, SECRET_SYNC_NAME_MAP } from "@app/services/secret-sync/secret-sync-maps";
import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types";
-// We don't allow initial sync import combined with recursive, because it can change the shape of
-// how secrets are organized in Infisical, which would then influence future syncs.
-const RECURSIVE_SYNC_REFINEMENT = {
- path: ["recursive"],
+// We don't allow initial sync import combined with including subfolders, because it can change the
+// shape of how secrets are organized in Infisical, which would then influence future syncs.
+const SUBFOLDER_SYNC_REFINEMENT = {
+ path: ["includeAllSubFolders"],
message:
"A sync that includes subfolders cannot also import existing secrets from the destination, because there is no single folder to import them into. Turn off subfolders, or set the first sync to overwrite the destination."
};
-const isRecursiveCombinationAllowed = (options: { recursive?: unknown; initialSyncBehavior?: unknown }) =>
- !options.recursive || options.initialSyncBehavior === SecretSyncInitialSyncBehavior.OverwriteDestination;
+const isSubFolderCombinationAllowed = (options: { includeAllSubFolders?: unknown; initialSyncBehavior?: unknown }) =>
+ !options.includeAllSubFolders || options.initialSyncBehavior === SecretSyncInitialSyncBehavior.OverwriteDestination;
// Shared by BaseSyncOptionsSchema and the recursive-conflicts preview route: both compile this
// string as a Handlebars template (getKeyWithSchema in secret-sync-payload.ts), so both need the
@@ -81,12 +81,12 @@ const BaseSyncOptionsSchema = <T extends AnyZodObject | undefined = undefined>({
disableSecretDeletion: supportsDisableSecretDeletion
? z.boolean().optional().describe(SecretSyncs.SYNC_OPTIONS(destination).disableSecretDeletion)
: z.literal(false).or(z.undefined()).describe(`Not supported for ${syncName} syncs.`),
- recursive: z.boolean().optional().describe(SecretSyncs.SYNC_OPTIONS(destination).recursive)
+ includeAllSubFolders: z.boolean().optional().describe(SecretSyncs.SYNC_OPTIONS(destination).includeAllSubFolders)
});
// What refinedSchema actually is: baseSchema, merged with the destination's own extra
// sync-option fields when `merge` supplies them, wrapped in a Zod effect that enforces
- // isRecursiveCombinationAllowed across the result.
+ // isSubFolderCombinationAllowed across the result.
type TRefinedSchema = z.ZodEffects<
T extends AnyZodObject
? z.ZodObject<z.objectUtil.MergeShapes<typeof baseSchema.shape, T["shape"]>>
@@ -98,8 +98,8 @@ const BaseSyncOptionsSchema = <T extends AnyZodObject | undefined = undefined>({
// above always agree, but the compiler has no way to prove that from a runtime value.
const refinedSchema = (
merge
- ? baseSchema.merge(merge).refine(isRecursiveCombinationAllowed, RECURSIVE_SYNC_REFINEMENT)
- : baseSchema.refine(isRecursiveCombinationAllowed, RECURSIVE_SYNC_REFINEMENT)
+ ? baseSchema.merge(merge).refine(isSubFolderCombinationAllowed, SUBFOLDER_SYNC_REFINEMENT)
+ : baseSchema.refine(isSubFolderCombinationAllowed, SUBFOLDER_SYNC_REFINEMENT)
) as TRefinedSchema;
return refinedSchema.describe(
diff --git a/backend/src/services/secret-sync/secret-sync-service.ts b/backend/src/services/secret-sync/secret-sync-service.ts
index d3052b23d7..95f8ae126e 100644
--- a/backend/src/services/secret-sync/secret-sync-service.ts
+++ b/backend/src/services/secret-sync/secret-sync-service.ts
@@ -139,7 +139,8 @@ export const secretSyncServiceFactory = ({
const preSaveTransformDeps = { secretV2BridgeDAL, appConnectionDAL, kmsService };
// The sync worker reads its folders with every access check disabled, so this is the only place
- // the actor's read access to them is established. A recursive sync reads the whole subtree, and
+ // the actor's read access to them is established. A sync including subfolders reads the whole
+ // subtree, and
// folder grants are per-folder rather than inherited, so checking only the root wouldn't catch a
// child folder the actor is denied on.
const $assertCanReadSyncedFolders = async (
@@ -149,13 +150,13 @@ export const secretSyncServiceFactory = ({
environment,
sourcePath,
sourceFolderId,
- recursive
+ includeAllSubFolders
}: {
projectId: string;
environment: string;
sourcePath: string;
sourceFolderId: string;
- recursive: boolean;
+ includeAllSubFolders: boolean;
}
) => {
const folders = await getSyncedFolders({
@@ -165,7 +166,7 @@ export const secretSyncServiceFactory = ({
environment,
sourcePath,
sourceFolderId,
- recursive
+ includeAllSubFolders
});
for (const { path } of folders) {
@@ -189,7 +190,7 @@ export const secretSyncServiceFactory = ({
};
// Shared by $assertSyncedSecretsAreFlattenable and findRecursiveConflicts: both need the same
- // decrypt-and-expand payload for the full recursive subtree, and differ only in what they do
+ // decrypt-and-expand payload for the whole source subtree, and differ only in what they do
// with it once built (throw on the first conflict vs. report every conflict back).
const $buildRecursiveSyncPayload = async ({
projectId,
@@ -234,7 +235,7 @@ export const secretSyncServiceFactory = ({
environment,
sourcePath,
sourceFolderId,
- syncOptions: { recursive: true, keySchema },
+ syncOptions: { includeAllSubFolders: true, keySchema },
includeImports: true
},
{
@@ -264,8 +265,8 @@ export const secretSyncServiceFactory = ({
// Flattening a subtree onto a destination that holds one flat list can produce two secrets with
// the same destination key. flatten() is what detects that, and the job runs it on every sync, so
// calling it here means a user reads the same sentence at save time and when the sync later drifts
- // into the same state. Callers only call this for a recursive sync — a non-recursive one covers a
- // single folder, where flatten() can never find a conflict.
+ // into the same state. Callers only call this for a sync that includes subfolders — one that does
+ // not covers a single folder, where flatten() can never find a conflict.
const $assertSyncedSecretsAreFlattenable = async ({
projectId,
actorOrgId,
@@ -346,7 +347,7 @@ export const secretSyncServiceFactory = ({
environment,
sourcePath: secretPath,
sourceFolderId: folder.id,
- recursive: true
+ includeAllSubFolders: true
});
const payload = await $buildRecursiveSyncPayload({
@@ -662,20 +663,21 @@ export const secretSyncServiceFactory = ({
});
const requestedSyncOptions = params.syncOptions;
- const isRecursive = Boolean(requestedSyncOptions?.recursive);
+ const includeAllSubFolders = Boolean(requestedSyncOptions?.includeAllSubFolders);
await $assertCanReadSyncedFolders(projectPermission, {
projectId,
environment,
sourcePath: secretPath,
sourceFolderId: folder.id,
- recursive: isRecursive
+ includeAllSubFolders
});
// Some destinations store secrets in a single flat list rather than a folder hierarchy, so a
- // recursive sync must flatten its whole subtree to one namespace. Check that it can here, so
+ // sync including subfolders must flatten its whole subtree to one namespace. Check that it can
+ // here, so
// the sync doesn't get created only to fail immediately on its first run.
- if (isRecursive) {
+ if (includeAllSubFolders) {
await $assertSyncedSecretsAreFlattenable({
projectId,
actorOrgId: actor.orgId,
@@ -909,14 +911,16 @@ export const secretSyncServiceFactory = ({
// so the gate cannot authorize one sync while the row ends up describing another.
const updatedSyncOptions = resolvedSyncOptions ?? (secretSync.syncOptions as Record<string, unknown> | undefined);
- const { recursive, keySchema } = (updatedSyncOptions ?? {}) as NonNullable<TSecretSync["syncOptions"]>;
- const isRecursive = Boolean(recursive);
+ const { includeAllSubFolders: requestedSubFolders, keySchema } = (updatedSyncOptions ?? {}) as NonNullable<
+ TSecretSync["syncOptions"]
+ >;
+ const includeAllSubFolders = Boolean(requestedSubFolders);
- // Every update to a recursive sync re-authorizes the whole subtree, because an actor holding
- // Edit on the source folder can otherwise repoint an existing recursive sync at a destination
- // they control and read descendants they were never granted. A non-recursive sync covers only
- // its source folder, so it re-authorizes when that source actually changes.
- if (isSourceChanged || isRecursive) {
+ // Every update to a sync that includes subfolders re-authorizes the whole subtree, because an
+ // actor holding Edit on the source folder can otherwise repoint it at a destination they control
+ // and read descendants they were never granted. A sync covering only its source folder
+ // re-authorizes when that source actually changes.
+ if (isSourceChanged || includeAllSubFolders) {
if (!updatedEnvironment || !updatedSecretPath)
throw new BadRequestError({ message: "Must specify both source environment and secret path" });
@@ -930,10 +934,10 @@ export const secretSyncServiceFactory = ({
environment: updatedEnvironment,
sourcePath: updatedSecretPath,
sourceFolderId: folderId,
- recursive: isRecursive
+ includeAllSubFolders
});
- if (isRecursive) {
+ if (includeAllSubFolders) {
await $assertSyncedSecretsAreFlattenable({
projectId: secretSync.projectId,
actorOrgId: actor.orgId,
diff --git a/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx b/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
index 1658080bd1..2c88e9ffca 100644
--- a/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
+++ b/frontend/src/components/secret-syncs/forms/CreateSecretSyncForm.tsx
@@ -251,7 +251,8 @@ export const CreateSecretSyncForm = ({
environment: watch("environment")?.slug,
secretPath: watch("secretPath"),
keySchema,
- recursive: Boolean(watch("syncOptions.recursive")) && !importsFromDestination
+ includeAllSubFolders:
+ Boolean(watch("syncOptions.includeAllSubFolders")) && !importsFromDestination
});
const isStepValid = async (index: number) => trigger(formTabs[index].fields);
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx
index e7297c40c7..70fd239c37 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncInitialSyncBehaviorFields.tsx
@@ -344,7 +344,7 @@ export const SecretSyncInitialSyncBehaviorFields = () => {
const currentInitialBehavior = watch("syncOptions.initialSyncBehavior");
const disableSecretDeletion = watch("syncOptions.disableSecretDeletion");
const keySchema = watch("syncOptions.keySchema");
- const recursive = Boolean(watch("syncOptions.recursive"));
+ const includeAllSubFolders = Boolean(watch("syncOptions.includeAllSubFolders"));
// Vercel "sensitive" secrets cannot be read back, so importing destination secrets is impossible.
// Force the initial sync behavior to OverwriteDestination whenever sensitive is enabled.
@@ -363,14 +363,15 @@ export const SecretSyncInitialSyncBehaviorFields = () => {
// A sync that includes subfolders has no single folder to import destination secrets back into,
// so overwrite is its only option. The source step sets that when the toggle goes on; this keeps
// the choice from being offered again here.
- const importAvailable = Boolean(syncOption?.canImportSecrets) && !vercelSensitive && !recursive;
+ const importAvailable =
+ Boolean(syncOption?.canImportSecrets) && !vercelSensitive && !includeAllSubFolders;
const behaviorKeys = importAvailable
? BEHAVIOR_ORDER
: [SecretSyncInitialSyncBehavior.OverwriteDestination];
return (
<>
- {recursive && syncOption?.canImportSecrets && (
+ {includeAllSubFolders && syncOption?.canImportSecrets && (
<Alert className="mb-3" variant="info">
<Info />
<AlertTitle>Importing secrets is not supported with subfolders</AlertTitle>
@@ -380,7 +381,7 @@ export const SecretSyncInitialSyncBehaviorFields = () => {
</AlertDescription>
</Alert>
)}
- {!vercelSensitive && !recursive && !syncOption?.canImportSecrets && (
+ {!vercelSensitive && !includeAllSubFolders && !syncOption?.canImportSecrets && (
<Alert className="mb-3" variant="warning">
<TriangleAlert />
<AlertTitle>Importing secrets is not supported</AlertTitle>
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
index ae52c8e7b8..f600eca360 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx
@@ -99,7 +99,7 @@ export const SecretSyncReviewFields = () => {
connection,
environment,
secretPath,
- syncOptions: { disableSecretDeletion, initialSyncBehavior, keySchema, recursive },
+ syncOptions: { disableSecretDeletion, initialSyncBehavior, keySchema, includeAllSubFolders },
destination,
isAutoSyncEnabled
} = watch();
@@ -361,10 +361,10 @@ export const SecretSyncReviewFields = () => {
</Detail>
{AdditionalSyncOptionsFieldsComponent}
<Detail>
- <DetailLabel>Include Subfolders</DetailLabel>
+ <DetailLabel>Include All Subfolders</DetailLabel>
<DetailValue>
- <Badge variant={recursive ? "success" : "neutral"}>
- {recursive ? "Enabled" : "Disabled"}
+ <Badge variant={includeAllSubFolders ? "success" : "neutral"}>
+ {includeAllSubFolders ? "Enabled" : "Disabled"}
</Badge>
</DetailValue>
</Detail>
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncSourceFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncSourceFields.tsx
index 4c08036656..8da450fe32 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncSourceFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncSourceFields.tsx
@@ -45,7 +45,7 @@ const DefaultSecretSyncSourceFields = () => {
const destination = watch("destination");
const selectedEnvironment = watch("environment");
const selectedSecretPath = watch("secretPath");
- const recursive = watch("syncOptions.recursive");
+ const includeAllSubFolders = watch("syncOptions.includeAllSubFolders");
const keySchema = watch("syncOptions.keySchema");
const { syncOption } = useSecretSyncOption(destination);
@@ -56,7 +56,7 @@ const DefaultSecretSyncSourceFields = () => {
environment: selectedEnvironment?.slug,
secretPath: selectedSecretPath,
keySchema,
- recursive: Boolean(recursive)
+ includeAllSubFolders: Boolean(includeAllSubFolders)
});
useEffect(() => {
@@ -128,19 +128,19 @@ const DefaultSecretSyncSourceFields = () => {
/>
<Controller
control={control}
- name="syncOptions.recursive"
+ name="syncOptions.includeAllSubFolders"
render={({ field: { value, onChange }, fieldState: { error } }) => (
<Field>
<Field orientation="horizontal">
<FieldContent>
- <Label htmlFor="recursive">Include secrets from subfolders</Label>
+ <Label htmlFor="includeAllSubFolders">Include secrets from all subfolders</Label>
<FieldDescription>
Also sync secrets from every folder beneath this path, however deep. Secret names
must be unique across all of them.
</FieldDescription>
</FieldContent>
<Toggle
- id="recursive"
+ id="includeAllSubFolders"
variant="project"
checked={Boolean(value)}
onCheckedChange={(checked) => {
diff --git a/frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts
index ff7f006cfa..109d269b29 100644
--- a/frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts
+++ b/frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts
@@ -9,7 +9,7 @@ export const BaseSecretSyncSchema = <T extends AnyZodObject | undefined = undefi
const baseSyncOptionsSchema = z.object({
initialSyncBehavior: z.nativeEnum(SecretSyncInitialSyncBehavior),
disableSecretDeletion: z.boolean().optional().default(false),
- recursive: z.boolean().optional(),
+ includeAllSubFolders: z.boolean().optional(),
keySchema: z
.string()
.optional()
diff --git a/frontend/src/hooks/api/secretSyncs/types/root-sync.ts b/frontend/src/hooks/api/secretSyncs/types/root-sync.ts
index 9d86bb0a6c..b8fbd4609c 100644
--- a/frontend/src/hooks/api/secretSyncs/types/root-sync.ts
+++ b/frontend/src/hooks/api/secretSyncs/types/root-sync.ts
@@ -5,7 +5,7 @@ export type RootSyncOptions = {
initialSyncBehavior: SecretSyncInitialSyncBehavior;
disableSecretDeletion?: boolean;
keySchema?: string;
- recursive?: boolean;
+ includeAllSubFolders?: boolean;
};
export type TRootSecretSync = {
diff --git a/frontend/src/hooks/api/secretSyncs/useRecursiveConflictsCheck.ts b/frontend/src/hooks/api/secretSyncs/useRecursiveConflictsCheck.ts
index 58c9740c15..2ec82120cb 100644
--- a/frontend/src/hooks/api/secretSyncs/useRecursiveConflictsCheck.ts
+++ b/frontend/src/hooks/api/secretSyncs/useRecursiveConflictsCheck.ts
@@ -6,7 +6,7 @@ type UseRecursiveConflictsCheckProps = {
environment?: string;
secretPath?: string;
keySchema?: string;
- recursive: boolean;
+ includeAllSubFolders: boolean;
};
export const useRecursiveConflictsCheck = ({
@@ -15,9 +15,9 @@ export const useRecursiveConflictsCheck = ({
environment,
secretPath,
keySchema,
- recursive
+ includeAllSubFolders
}: UseRecursiveConflictsCheckProps) => {
- const shouldCheck = recursive && Boolean(environment) && Boolean(secretPath);
+ const shouldCheck = includeAllSubFolders && Boolean(environment) && Boolean(secretPath);
const { data, isLoading, isSuccess, error } = useCheckRecursiveConflicts(
destination,