diff --git a/backend/src/services/secret-sync/github/github-sync-fns.ts b/backend/src/services/secret-sync/github/github-sync-fns.ts index 39d458b68..8e0759d11 100644 --- a/backend/src/services/secret-sync/github/github-sync-fns.ts +++ b/backend/src/services/secret-sync/github/github-sync-fns.ts @@ -2,7 +2,7 @@ import { Octokit } from "@octokit/rest"; import sodium from "libsodium-wrappers"; import { getGitHubClient } from "@app/services/app-connection/github"; -import { GitHubSyncScope } from "@app/services/secret-sync/github/github-sync-enums"; +import { GitHubSyncScope, GitHubSyncVisibility } from "@app/services/secret-sync/github/github-sync-enums"; import { SECRET_SYNC_NAME_MAP } from "@app/services/secret-sync/secret-sync-maps"; import { TSecretMap } from "@app/services/secret-sync/secret-sync-types"; @@ -149,7 +149,9 @@ const putSecret = async (client: Octokit, secretSync: TGitHubSyncWithCredentials org: destinationConfig.org, ...payload, visibility, - selected_repository_ids: selectedRepositoryIds + ...(visibility === GitHubSyncVisibility.Selected && { + selected_repository_ids: selectedRepositoryIds + }) }); break; } diff --git a/backend/src/services/secret-sync/github/github-sync-schemas.ts b/backend/src/services/secret-sync/github/github-sync-schemas.ts index 6f802ed90..0302312c9 100644 --- a/backend/src/services/secret-sync/github/github-sync-schemas.ts +++ b/backend/src/services/secret-sync/github/github-sync-schemas.ts @@ -34,10 +34,20 @@ const GitHubSyncDestinationConfigSchema = z .superRefine((options, ctx) => { if (options.scope !== GitHubSyncScope.Organization) return; - if (options.visibility === GitHubSyncVisibility.Selected && !options.selectedRepositoryIds?.length) { + if (options.visibility === GitHubSyncVisibility.Selected) { + if (!options.selectedRepositoryIds?.length) + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: "Select at least 1 repository", + path: ["selectedRepositoryIds"] + }); + return; + } + + if (options.selectedRepositoryIds?.length) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: "Select at least 1 repository", + message: `Selected repositories is only supported for visibility "Selected"`, path: ["selectedRepositoryIds"] }); } diff --git a/frontend/src/components/secret-syncs/SecretSyncImportSecretsModal.tsx b/frontend/src/components/secret-syncs/SecretSyncImportSecretsModal.tsx index 99334294f..aab8a4243 100644 --- a/frontend/src/components/secret-syncs/SecretSyncImportSecretsModal.tsx +++ b/frontend/src/components/secret-syncs/SecretSyncImportSecretsModal.tsx @@ -107,7 +107,7 @@ const Content = ({ secretSync, onComplete }: ContentProps) => { } errorText={error?.message} isError={Boolean(error?.message)} - label="Initial Sync Behavior" + label="Import Behavior" >