Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/sim/background/schedule-execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,11 @@ async function runWorkflowExecution({

const mergedStates = mergeSubblockState(blocks)

// Use workflow creator's userId for personal env vars (not the billing actor)
// This ensures pre-checks match the execution behavior in execution-core.ts
const envVarUserId = workflowRecord.userId || actorUserId
const { personalEncrypted, workspaceEncrypted } = await getPersonalAndWorkspaceEnv(
actorUserId,
envVarUserId,
workflowRecord.workspaceId || undefined
)

Expand Down
7 changes: 6 additions & 1 deletion apps/sim/lib/workflows/executor/execution-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,13 @@ export async function executeWorkflowCore(
// Merge block states
const mergedStates = mergeSubblockState(blocks)

// Use workflow creator's userId for personal env vars (not the billing actor)
// This ensures that {{variable}} references in the workflow resolve to the
// creator's personal environment variables, not the workspace billing account's.
// For shared workspace workflows, workspace-scoped env vars are recommended.
const envVarUserId = workflow.userId || userId
const { personalEncrypted, workspaceEncrypted, personalDecrypted, workspaceDecrypted } =
await getPersonalAndWorkspaceEnv(userId, providedWorkspaceId)
await getPersonalAndWorkspaceEnv(envVarUserId, providedWorkspaceId)

// Use encrypted values for logging (don't log decrypted secrets)
const variables = EnvVarsSchema.parse({ ...personalEncrypted, ...workspaceEncrypted })
Expand Down