use declared outputSchema for logic-function steps (#20679)

When a logic function declares
`workflowActionTriggerSettings.outputSchema`, use it as the step's
initial output schema so downstream steps can pick variables without
first running the Test tab. A successful test run still overrides the
schema with the inferred shape, preserving "test wins" behavior. Falls
back to the existing "Generate Function Output" LINK placeholder when no
schema is declared (custom code steps, older functions).


https://github.com/user-attachments/assets/af9c45ed-d623-4234-be9f-46812fd06e2e
This commit is contained in:
Abdul Rahman
2026-05-19 20:11:00 +05:30
committed by GitHub
parent 827f24df2b
commit 08e7e4819b
4 changed files with 233 additions and 9 deletions
@@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { inputSchemaToOutputSchema } from 'twenty-shared/logic-function';
import {
FieldMetadataType,
StepLogicalOperator,
@@ -33,6 +34,7 @@ import {
} from 'src/modules/workflow/common/exceptions/workflow-version-step.exception';
import { type WorkflowVersionWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-version.workspace-entity';
import { WorkflowCommonWorkspaceService } from 'src/modules/workflow/common/workspace-services/workflow-common.workspace-service';
import { type OutputSchema } from 'src/modules/workflow/workflow-builder/workflow-schema/types/output-schema.type';
import { CodeStepBuildService } from 'src/modules/workflow/workflow-builder/workflow-version-step/code-step/services/code-step-build.service';
import { type BaseWorkflowActionSettings } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-settings.type';
import {
@@ -220,6 +222,23 @@ export class WorkflowVersionStepOperationsWorkspaceService {
flatLogicFunctionMaps,
});
const declaredOutputSchema =
flatLogicFunction.workflowActionTriggerSettings?.outputSchema;
const initialOutputSchema: OutputSchema = isDefined(
declaredOutputSchema,
)
? inputSchemaToOutputSchema(declaredOutputSchema)
: {
link: {
isLeaf: true,
icon: 'IconVariable',
tab: 'test',
label: 'Generate Function Output',
},
_outputSchemaType: 'LINK',
};
return {
builtStep: {
...baseStep,
@@ -229,15 +248,7 @@ export class WorkflowVersionStepOperationsWorkspaceService {
type: WorkflowActionType.LOGIC_FUNCTION,
settings: {
...BASE_STEP_DEFINITION,
outputSchema: {
link: {
isLeaf: true,
icon: 'IconVariable',
tab: 'test',
label: 'Generate Function Output',
},
_outputSchemaType: 'LINK',
},
outputSchema: initialOutputSchema,
input: {
logicFunctionId,
logicFunctionInput: isDefined(