From a7d2d134d0bc85124b45d426cf15dbb1ff097d41 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Mon, 6 Apr 2026 16:56:49 +0300 Subject: [PATCH] fix(stacks): stack.env can be null [BE-12736] (#2241) --- .../useCreateStack/createStandaloneStackFromFileContent.ts | 2 +- .../queries/useCreateStack/createSwarmStackFromFileContent.ts | 2 +- app/react/common/stacks/types.ts | 4 ++-- .../docker/stacks/ItemView/StackEditorTab/StackEditorTab.tsx | 2 +- .../StackDuplicationForm/useDuplicateStackMutation.ts | 2 +- .../StackRedeployGitForm/StackRedeployGitForm.tsx | 2 +- app/react/docker/stacks/useUpdateStack.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/react/common/stacks/queries/useCreateStack/createStandaloneStackFromFileContent.ts b/app/react/common/stacks/queries/useCreateStack/createStandaloneStackFromFileContent.ts index 4f3331756..96f22c97a 100644 --- a/app/react/common/stacks/queries/useCreateStack/createStandaloneStackFromFileContent.ts +++ b/app/react/common/stacks/queries/useCreateStack/createStandaloneStackFromFileContent.ts @@ -13,7 +13,7 @@ export interface StandaloneFileContentPayload { stackFileContent: string; /** List of environment variables */ - env?: Array; + env?: Array | null; /** Whether the stack is from an app template */ fromAppTemplate?: boolean; diff --git a/app/react/common/stacks/queries/useCreateStack/createSwarmStackFromFileContent.ts b/app/react/common/stacks/queries/useCreateStack/createSwarmStackFromFileContent.ts index fadeeb594..d38a8b29f 100644 --- a/app/react/common/stacks/queries/useCreateStack/createSwarmStackFromFileContent.ts +++ b/app/react/common/stacks/queries/useCreateStack/createSwarmStackFromFileContent.ts @@ -13,7 +13,7 @@ export interface SwarmFileContentPayload { stackFileContent: string; /** List of environment variables */ - env?: Array; + env?: Array | null; /** Whether the stack is from an app template */ fromAppTemplate?: boolean; diff --git a/app/react/common/stacks/types.ts b/app/react/common/stacks/types.ts index 24889dcbe..b4c7a70c3 100644 --- a/app/react/common/stacks/types.ts +++ b/app/react/common/stacks/types.ts @@ -54,7 +54,7 @@ export interface Stack { EndpointId: number; SwarmId: string; EntryPoint: string; - Env: EnvVar[]; + Env: EnvVar[] | null; ResourceControl?: ResourceControlResponse; Status: StackStatus; ProjectPath: string; @@ -84,7 +84,7 @@ export type StackFile = { }; export interface GitStackPayload { - env: Array; + env: Array | null; prune?: boolean; RepositoryReferenceName?: string; RepositoryAuthentication?: boolean; diff --git a/app/react/docker/stacks/ItemView/StackEditorTab/StackEditorTab.tsx b/app/react/docker/stacks/ItemView/StackEditorTab/StackEditorTab.tsx index 5e1ebfe2e..d581e66a1 100644 --- a/app/react/docker/stacks/ItemView/StackEditorTab/StackEditorTab.tsx +++ b/app/react/docker/stacks/ItemView/StackEditorTab/StackEditorTab.tsx @@ -57,7 +57,7 @@ export function StackEditorTab({ ); const initialValues: StackEditorFormValues = { - environmentVariables: stack.Env, + environmentVariables: stack.Env || [], prune: !!(stack.Option && stack.Option.Prune), stackFileContent: originalFileContent, enabledWebhook: !!stack.Webhook, diff --git a/app/react/docker/stacks/ItemView/StackInfoTab/StackDuplicationForm/useDuplicateStackMutation.ts b/app/react/docker/stacks/ItemView/StackInfoTab/StackDuplicationForm/useDuplicateStackMutation.ts index 83fa00c16..ebd4aeca7 100644 --- a/app/react/docker/stacks/ItemView/StackInfoTab/StackDuplicationForm/useDuplicateStackMutation.ts +++ b/app/react/docker/stacks/ItemView/StackInfoTab/StackDuplicationForm/useDuplicateStackMutation.ts @@ -25,7 +25,7 @@ export async function duplicateStack({ fileContent: string; targetEnvironmentId: EnvironmentId; type: StackType; - env?: Array; + env?: Array | null; }) { if (type === StackType.DockerSwarm) { const swarm = await getSwarm(targetEnvironmentId); diff --git a/app/react/docker/stacks/ItemView/StackInfoTab/StackRedeployGitForm/StackRedeployGitForm.tsx b/app/react/docker/stacks/ItemView/StackInfoTab/StackRedeployGitForm/StackRedeployGitForm.tsx index 0b287c68b..17a6a9023 100644 --- a/app/react/docker/stacks/ItemView/StackInfoTab/StackRedeployGitForm/StackRedeployGitForm.tsx +++ b/app/react/docker/stacks/ItemView/StackInfoTab/StackRedeployGitForm/StackRedeployGitForm.tsx @@ -46,7 +46,7 @@ export function StackRedeployGitForm({ stack }: { stack: Stack }) { SaveCredential: false, }, autoUpdate: parseAutoUpdateResponse(stack.AutoUpdate), - env: stack.Env, + env: stack.Env || [], prune: stack.Option?.Prune || false, refName: stack.GitConfig?.ReferenceName || '', tlsSkipVerify: stack.GitConfig?.TLSSkipVerify || false, diff --git a/app/react/docker/stacks/useUpdateStack.ts b/app/react/docker/stacks/useUpdateStack.ts index 91aadb9c8..877e0dffd 100644 --- a/app/react/docker/stacks/useUpdateStack.ts +++ b/app/react/docker/stacks/useUpdateStack.ts @@ -15,7 +15,7 @@ export function useUpdateStackMutation() { type Payload = { stackFileContent: string; - env?: EnvVarValues; + env?: EnvVarValues | null; prune?: boolean; webhook?: string; repullImageAndRedeploy?: boolean;