fix(env-vars): refactor for workspace/personal env vars to work with server side execution correctly (#2197)

* fix(env-var-resolution): new executor env var resolution changes

* add sessionuser id"

* cleanup code

* add doc update

* fix build

* fix client session pass through"

* add type change

* fix env var with hitl

* fix types
This commit is contained in:
Vikhyath Mondreti
2025-12-04 21:08:20 -08:00
committed by GitHub
parent ca818a6503
commit 8ef9a45125
18 changed files with 479 additions and 619 deletions

View File

@@ -121,6 +121,7 @@ export class DAGExecutor {
blockStates: state.getBlockStates(),
blockLogs: snapshotState?.blockLogs ?? [],
metadata: {
...this.contextExtensions.metadata,
startTime: new Date().toISOString(),
duration: 0,
useDraftState: this.contextExtensions.isDeployedContext !== true,

View File

@@ -1,18 +1,16 @@
import type { DAG } from '@/executor/dag/builder'
import type { SerializableExecutionState } from '@/executor/execution/snapshot'
import { ExecutionSnapshot } from '@/executor/execution/snapshot'
import type { ExecutionContext, ExecutionMetadata, SerializedSnapshot } from '@/executor/types'
import {
type ExecutionMetadata,
ExecutionSnapshot,
type SerializableExecutionState,
} from '@/executor/execution/snapshot'
import type { ExecutionContext, SerializedSnapshot } from '@/executor/types'
function mapFromEntries<T>(map?: Map<string, T>): Record<string, T> | undefined {
if (!map) return undefined
return Object.fromEntries(map)
}
function setToArray<T>(set?: Set<T>): T[] | undefined {
if (!set) return undefined
return Array.from(set)
}
function serializeLoopExecutions(
loopExecutions?: Map<string, any>
): Record<string, any> | undefined {
@@ -96,27 +94,26 @@ export function serializePauseSnapshot(
dagIncomingEdges,
}
const executionMetadata = {
const executionMetadata: ExecutionMetadata = {
requestId:
(context.metadata as any)?.requestId ??
context.executionId ??
context.workflowId ??
'unknown',
metadataFromContext?.requestId ?? context.executionId ?? context.workflowId ?? 'unknown',
executionId: context.executionId ?? 'unknown',
workflowId: context.workflowId,
workspaceId: context.workspaceId,
userId: (context.metadata as any)?.userId ?? '',
triggerType: (context.metadata as any)?.triggerType ?? 'manual',
userId: metadataFromContext?.userId ?? '',
sessionUserId: metadataFromContext?.sessionUserId,
workflowUserId: metadataFromContext?.workflowUserId,
triggerType: metadataFromContext?.triggerType ?? 'manual',
triggerBlockId: triggerBlockIds[0],
useDraftState,
startTime: context.metadata.startTime ?? new Date().toISOString(),
startTime: metadataFromContext?.startTime ?? new Date().toISOString(),
isClientSession: metadataFromContext?.isClientSession,
}
const snapshot = new ExecutionSnapshot(
executionMetadata,
context.workflow,
{},
context.environmentVariables ?? {},
context.workflowVariables ?? {},
context.selectedOutputs ?? [],
state

View File

@@ -7,10 +7,13 @@ export interface ExecutionMetadata {
workflowId: string
workspaceId?: string
userId: string
sessionUserId?: string
workflowUserId?: string
triggerType: string
triggerBlockId?: string
useDraftState: boolean
startTime: string
isClientSession?: boolean
pendingBlocks?: string[]
resumeFromSnapshot?: boolean
workflowStateOverride?: {
@@ -57,7 +60,6 @@ export class ExecutionSnapshot {
public readonly metadata: ExecutionMetadata,
public readonly workflow: any,
public readonly input: any,
public readonly environmentVariables: Record<string, string>,
public readonly workflowVariables: Record<string, any>,
public readonly selectedOutputs: string[] = [],
public readonly state?: SerializableExecutionState
@@ -68,7 +70,6 @@ export class ExecutionSnapshot {
metadata: this.metadata,
workflow: this.workflow,
input: this.input,
environmentVariables: this.environmentVariables,
workflowVariables: this.workflowVariables,
selectedOutputs: this.selectedOutputs,
state: this.state,
@@ -81,7 +82,6 @@ export class ExecutionSnapshot {
data.metadata,
data.workflow,
data.input,
data.environmentVariables,
data.workflowVariables,
data.selectedOutputs,
data.state

View File

@@ -1,3 +1,4 @@
import type { ExecutionMetadata, SerializableExecutionState } from '@/executor/execution/snapshot'
import type { BlockState, NormalizedBlockOutput } from '@/executor/types'
import type { SubflowType } from '@/stores/workflows/workflow/types'
@@ -19,7 +20,8 @@ export interface ContextExtensions {
targetHandle?: string
}>
dagIncomingEdges?: Record<string, string[]>
snapshotState?: import('@/executor/execution/snapshot').SerializableExecutionState
snapshotState?: SerializableExecutionState
metadata?: ExecutionMetadata
onStream?: (streamingExecution: unknown) => Promise<void>
onBlockStart?: (
blockId: string,