Skip to content

Commit b74ab46

Browse files
fix(e2b-env-var): use isTruthy and getEnv (#1228)
1 parent 533b4c5 commit b74ab46

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

apps/sim/app/api/function/execute/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createContext, Script } from 'vm'
22
import { type NextRequest, NextResponse } from 'next/server'
3+
import { env, isTruthy } from '@/lib/env'
34
import { executeInE2B } from '@/lib/execution/e2b'
45
import { CodeLanguage, DEFAULT_CODE_LANGUAGE, isValidCodeLanguage } from '@/lib/execution/languages'
56
import { createLogger } from '@/lib/logs/console/logger'
@@ -579,7 +580,7 @@ export async function POST(req: NextRequest) {
579580
resolvedCode = codeResolution.resolvedCode
580581
const contextVariables = codeResolution.contextVariables
581582

582-
const e2bEnabled = process.env.E2B_ENABLED === 'true'
583+
const e2bEnabled = isTruthy(env.E2B_ENABLED)
583584
const lang = isValidCodeLanguage(language) ? language : DEFAULT_CODE_LANGUAGE
584585
const useE2B =
585586
e2bEnabled &&

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/e2b-switch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Info } from 'lucide-react'
22
import { Label, Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui'
33
import { Switch as UISwitch } from '@/components/ui/switch'
4-
import { env } from '@/lib/env'
4+
import { getEnv, isTruthy } from '@/lib/env'
55
import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/hooks/use-sub-block-value'
66

77
interface E2BSwitchProps {
@@ -23,7 +23,7 @@ export function E2BSwitch({
2323
previewValue,
2424
disabled = false,
2525
}: E2BSwitchProps) {
26-
const e2bEnabled = env.NEXT_PUBLIC_E2B_ENABLED === 'true'
26+
const e2bEnabled = isTruthy(getEnv('NEXT_PUBLIC_E2B_ENABLED'))
2727
if (!e2bEnabled) return null
2828

2929
const [storeValue, setStoreValue] = useSubBlockValue<boolean>(blockId, subBlockId)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Badge } from '@/components/ui/badge'
66
import { Button } from '@/components/ui/button'
77
import { Card } from '@/components/ui/card'
88
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
9-
import { env } from '@/lib/env'
9+
import { getEnv, isTruthy } from '@/lib/env'
1010
import { createLogger } from '@/lib/logs/console/logger'
1111
import { parseCronToHumanReadable } from '@/lib/schedules/utils'
1212
import { cn, validateName } from '@/lib/utils'
@@ -443,7 +443,7 @@ export function WorkflowBlock({ id, data }: NodeProps<WorkflowBlockProps>) {
443443
const isTriggerMode = useWorkflowStore.getState().blocks[blockId]?.triggerMode ?? false
444444
const effectiveAdvanced = currentWorkflow.isDiffMode ? displayAdvancedMode : isAdvancedMode
445445
const effectiveTrigger = currentWorkflow.isDiffMode ? displayTriggerMode : isTriggerMode
446-
const e2bClientEnabled = env.NEXT_PUBLIC_E2B_ENABLED === 'true'
446+
const e2bClientEnabled = isTruthy(getEnv('NEXT_PUBLIC_E2B_ENABLED'))
447447

448448
// Filter visible blocks and those that meet their conditions
449449
const visibleSubBlocks = subBlocks.filter((block) => {

0 commit comments

Comments
 (0)