Skip to content

Commit 4dec9f9

Browse files
committed
fix(cli): make syncEnvVarsWithServer no-op safe for empty input
1 parent 82f01f7 commit 4dec9f9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

packages/cli-v3/src/commands/deploy.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,11 @@ export async function syncEnvVarsWithServer(
788788
Object.keys(secretParentEnvVars ?? {}).length > 0;
789789

790790
// The import API applies isSecret per call, so secret and non-secret vars go in separate calls.
791-
let result: Awaited<ReturnType<typeof apiClient.importEnvVars>> | undefined;
791+
// Default to success so an all-empty call (no vars to sync) is a no-op, not undefined.
792+
let result: Awaited<ReturnType<typeof apiClient.importEnvVars>> = {
793+
success: true,
794+
data: { success: true },
795+
};
792796

793797
if (hasNonSecret) {
794798
result = await apiClient.importEnvVars(projectRef, environmentSlug, {
@@ -798,7 +802,7 @@ export async function syncEnvVarsWithServer(
798802
});
799803
}
800804

801-
if (hasSecret && (!result || result.success)) {
805+
if (hasSecret && result.success) {
802806
result = await apiClient.importEnvVars(projectRef, environmentSlug, {
803807
variables: secretEnvVars ?? {},
804808
parentVariables: secretParentEnvVars,
@@ -807,7 +811,7 @@ export async function syncEnvVarsWithServer(
807811
});
808812
}
809813

810-
return result!;
814+
return result;
811815
}
812816

813817
async function failDeploy(

0 commit comments

Comments
 (0)