AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(flows): renaming a step no longer marks it as needing a re-test (#15443)
Bartosz Majewski3238be526e15
diff --git a/bun.lock b/bun.lockindex 03b68786134..0fcf1622a72 100644--- a/bun.lock+++ b/bun.lock@@ -1,6 +1,5 @@{"lockfileVersion": 1,- "configVersion": 0,"workspaces": {"": {"name": "activepieces",@@ -122,7 +121,7 @@},"packages/core/execution": {"name": "@activepieces/core-execution",- "version": "0.26.1",+ "version": "0.26.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -190,7 +189,7 @@},"packages/core/utils": {"name": "@activepieces/core-utils",- "version": "0.10.0",+ "version": "0.10.1","dependencies": {"deepmerge-ts": "8.0.2","ipaddr.js": "2.3.0",@@ -552,7 +551,7 @@},"packages/pieces/community/amazon-s3": {"name": "@activepieces/piece-amazon-s3",- "version": "0.7.1",+ "version": "0.8.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3054,7 +3053,7 @@},"packages/pieces/community/facebook-leads": {"name": "@activepieces/piece-facebook-leads",- "version": "0.3.7",+ "version": "0.4.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7888,7 +7887,7 @@},"packages/pieces/community/rss": {"name": "@activepieces/piece-rss",- "version": "0.6.0",+ "version": "0.7.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/packages/core/execution/package.json b/packages/core/execution/package.jsonindex 449d9e2ce2c..b010c18879c 100644--- a/packages/core/execution/package.json+++ b/packages/core/execution/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/core-execution",- "version": "0.26.1",+ "version": "0.26.2","type": "commonjs","main": "./dist/src/index.js","scripts": {diff --git a/packages/core/execution/src/lib/flows/operations/update-action.ts b/packages/core/execution/src/lib/flows/operations/update-action.tsindex 85bd17b1ad0..4432e0cfa51 100644--- a/packages/core/execution/src/lib/flows/operations/update-action.ts+++ b/packages/core/execution/src/lib/flows/operations/update-action.ts@@ -4,6 +4,7 @@ import { FlowAction, FlowActionType, SingleActionSchema } from '../actions/actioimport { FlowVersion } from '../flow-version'import { flowStructureUtil } from '../util/flow-structure-util'import { UpdateActionRequest } from './index'+import { updateStepUtil } from './update-step-util'function _updateAction(flowVersion: FlowVersion, request: UpdateActionRequest): FlowVersion {const next = flowStructureUtil.transferFlow(flowVersion, (stepToUpdate) => {@@ -92,7 +93,7 @@ function _updateAction(flowVersion: FlowVersion, request: UpdateActionRequest):const parseResult = SingleActionSchema.safeParse(updatedAction)const valid = (isNil(request.valid) ? true : request.valid) && parseResult.successreturn {- ...updatedAction,+ ...updateStepUtil.preserveLastUpdatedDate({ existingStep: stepToUpdate, updatedStep: updatedAction }),valid,}})diff --git a/packages/core/execution/src/lib/flows/operations/update-step-util.ts b/packages/core/execution/src/lib/flows/operations/update-step-util.tsnew file mode 100644index 00000000000..3c79eb836da--- /dev/null+++ b/packages/core/execution/src/lib/flows/operations/update-step-util.ts@@ -0,0 +1,36 @@+import { deepEquals, prune } from '@activepieces/core-utils'+import { FlowAction } from '../actions/action'+import { FlowTrigger } from '../triggers/trigger'++function contentOf(step: FlowAction | FlowTrigger): Record<string, unknown> {+ const settings: Record<string, unknown> = { ...(step.settings ?? {}) }+ const input = settings['input']+ delete settings['input']+ delete settings['sampleData']+ delete settings['customLogoUrl']+ return {+ type: step.type,+ input: input ?? {},+ optionSettings: prune(settings),+ }+}++function preserveLastUpdatedDate<T extends FlowAction | FlowTrigger>({ existingStep, updatedStep }: PreserveLastUpdatedDateParams<T>): T {+ const contentChanged = !deepEquals({ a: contentOf(existingStep), b: contentOf(updatedStep) })+ if (contentChanged) {+ return updatedStep+ }+ return {+ ...updatedStep,+ lastUpdatedDate: existingStep.lastUpdatedDate,+ }+}++export const updateStepUtil = {+ preserveLastUpdatedDate,+}++type PreserveLastUpdatedDateParams<T extends FlowAction | FlowTrigger> = {+ existingStep: FlowAction | FlowTrigger+ updatedStep: T+}diff --git a/packages/core/execution/src/lib/flows/operations/update-trigger.ts b/packages/core/execution/src/lib/flows/operations/update-trigger.tsindex 2e1eff61236..4d0ce4cecbb 100644--- a/packages/core/execution/src/lib/flows/operations/update-trigger.ts+++ b/packages/core/execution/src/lib/flows/operations/update-trigger.ts@@ -6,6 +6,7 @@ import { SampleDataSettings } from '../sample-data'import { FlowTrigger, FlowTriggerType } from '../triggers/trigger'import { flowStructureUtil } from '../util/flow-structure-util'import { UpdateTriggerRequest } from '.'+import { updateStepUtil } from './update-step-util'function createTrigger(name: string, request: UpdateTriggerRequest, nextAction: FlowAction | undefined, existingSampleData: SampleDataSettings | undefined): FlowTrigger {@@ -45,9 +46,10 @@ function _updateTrigger(flowVersion: FlowVersion, request: UpdateTriggerRequest)const trigger = flowStructureUtil.getStepOrThrow(request.name, flowVersion.trigger)const existingSampleData = trigger.type === FlowTriggerType.PIECE ? trigger.settings.sampleData : undefinedconst updatedTrigger = createTrigger(request.name, request, trigger.nextAction, existingSampleData)+ const finalTrigger = updateStepUtil.preserveLastUpdatedDate({ existingStep: trigger, updatedStep: updatedTrigger })const next = flowStructureUtil.transferFlow(flowVersion, (parentStep) => {if (parentStep.name === request.name) {- return updatedTrigger+ return finalTrigger}return parentStep})diff --git a/packages/core/execution/test/flow/update-step-rename.test.ts b/packages/core/execution/test/flow/update-step-rename.test.tsnew file mode 100644index 00000000000..2cd258f0283--- /dev/null+++ b/packages/core/execution/test/flow/update-step-rename.test.ts@@ -0,0 +1,195 @@+import {+ FlowActionType,+ flowOperations,+ FlowOperationType,+ flowStructureUtil,+ FlowTriggerType,+ FlowVersion,+ FlowVersionState,+ PieceAction,+ PieceTrigger,+ PropertyExecutionType,+ UpdateActionRequest,+ UpdateTriggerRequest,+} from '../../src'++const TRIGGER_LAST_UPDATED = '2026-01-01T00:00:00.000Z'+const ACTION_LAST_UPDATED = '2026-01-02T00:00:00.000Z'+const TRIGGER_SAMPLE_FILE_ID = 'trigger_sample_file'+const ACTION_SAMPLE_FILE_ID = 'action_sample_file'++function createFlowVersion(): FlowVersion {+ return {+ id: 'pj0KQ7Aypoa9OQGHzmKDl',+ created: '2023-05-24T00:16:41.353Z',+ updated: '2023-05-24T00:16:41.353Z',+ flowId: 'lod6JEdKyPlvrnErdnrGa',+ updatedBy: '',+ displayName: 'Rename test',+ agentIds: [],+ notes: [],+ connectionIds: [],+ valid: true,+ state: FlowVersionState.DRAFT,+ trigger: {+ name: 'trigger',+ type: FlowTriggerType.PIECE,+ valid: true,+ displayName: 'Every Hour',+ lastUpdatedDate: TRIGGER_LAST_UPDATED,+ settings: {+ pieceName: 'schedule',+ pieceVersion: '0.0.2',+ triggerName: 'cron_expression',+ input: { cronExpression: '25 10 * * 0,1,2,3,4' },+ propertySettings: { cronExpression: { type: PropertyExecutionType.MANUAL } },+ sampleData: { sampleDataFileId: TRIGGER_SAMPLE_FILE_ID, lastTestDate: '2026-01-03T00:00:00.000Z' },+ },+ nextAction: {+ name: 'step_1',+ type: FlowActionType.PIECE,+ valid: true,+ displayName: 'Get',+ lastUpdatedDate: ACTION_LAST_UPDATED,+ settings: {+ pieceName: 'store',+ pieceVersion: '0.2.6',+ actionName: 'get',+ input: { key: '1' },+ propertySettings: { key: { type: PropertyExecutionType.MANUAL } },+ sampleData: { sampleDataFileId: ACTION_SAMPLE_FILE_ID, lastTestDate: '2026-01-03T00:00:00.000Z' },+ },+ },+ },+ }+}++function getAction(flowVersion: FlowVersion): PieceAction {+ const step = flowStructureUtil.getStepOrThrow('step_1', flowVersion.trigger)+ if (step.type !== FlowActionType.PIECE) {+ throw new Error('expected a piece action')+ }+ return step+}++function getTrigger(flowVersion: FlowVersion): PieceTrigger {+ if (flowVersion.trigger.type !== FlowTriggerType.PIECE) {+ throw new Error('expected a piece trigger')+ }+ return flowVersion.trigger+}++function applyActionUpdate(flowVersion: FlowVersion, overrides: Partial<UpdateActionRequest>): PieceAction {+ const action = getAction(flowVersion)+ const result = flowOperations.apply(flowVersion, {+ type: FlowOperationType.UPDATE_ACTION,+ request: {+ type: FlowActionType.PIECE,+ name: action.name,+ displayName: action.displayName,+ valid: action.valid,+ settings: action.settings,+ ...overrides,+ },+ })+ return getAction(result)+}++function applyTriggerUpdate(flowVersion: FlowVersion, overrides: Partial<UpdateTriggerRequest>): PieceTrigger {+ const trigger = getTrigger(flowVersion)+ const result = flowOperations.apply(flowVersion, {+ type: FlowOperationType.UPDATE_TRIGGER,+ request: {+ type: FlowTriggerType.PIECE,+ name: trigger.name,+ displayName: trigger.displayName,+ valid: trigger.valid,+ settings: trigger.settings,+ ...overrides,+ },+ })+ return getTrigger(result)+}++describe('rename-only updates keep the tested status (GIT-1873)', () => {+ it('CLAIM 1: UPDATE_ACTION changing only displayName keeps lastUpdatedDate and sample data', () => {+ const updated = applyActionUpdate(createFlowVersion(), { displayName: 'Get Renamed' })+ expect(updated.displayName).toBe('Get Renamed')+ expect(updated.lastUpdatedDate).toBe(ACTION_LAST_UPDATED)+ expect(updated.settings.sampleData?.sampleDataFileId).toBe(ACTION_SAMPLE_FILE_ID)+ })++ it('CLAIM 2: UPDATE_ACTION changing input still bumps lastUpdatedDate', () => {+ const flowVersion = createFlowVersion()+ const updated = applyActionUpdate(flowVersion, {+ settings: { ...getAction(flowVersion).settings, input: { key: '2' } },+ })+ expect(updated.lastUpdatedDate).not.toBe(ACTION_LAST_UPDATED)+ expect(updated.settings.sampleData?.sampleDataFileId).toBe(ACTION_SAMPLE_FILE_ID)+ })++ it('CLAIM 3: UPDATE_ACTION renaming and changing input together bumps lastUpdatedDate', () => {+ const flowVersion = createFlowVersion()+ const updated = applyActionUpdate(flowVersion, {+ displayName: 'Get Renamed',+ settings: { ...getAction(flowVersion).settings, input: { key: '2' } },+ })+ expect(updated.lastUpdatedDate).not.toBe(ACTION_LAST_UPDATED)+ })++ it('CLAIM 4: UPDATE_ACTION rename with stale sampleData in the request is still rename-only', () => {+ const flowVersion = createFlowVersion()+ const updated = applyActionUpdate(flowVersion, {+ displayName: 'Get Renamed',+ settings: { ...getAction(flowVersion).settings, sampleData: undefined },+ })+ expect(updated.lastUpdatedDate).toBe(ACTION_LAST_UPDATED)+ expect(updated.settings.sampleData?.sampleDataFileId).toBe(ACTION_SAMPLE_FILE_ID)+ })++ it('CLAIM 5: UPDATE_TRIGGER changing only displayName keeps lastUpdatedDate and sample data', () => {+ const updated = applyTriggerUpdate(createFlowVersion(), { displayName: 'Every Hour Renamed' })+ expect(updated.displayName).toBe('Every Hour Renamed')+ expect(updated.lastUpdatedDate).toBe(TRIGGER_LAST_UPDATED)+ expect(updated.settings.sampleData?.sampleDataFileId).toBe(TRIGGER_SAMPLE_FILE_ID)+ expect(updated.nextAction?.name).toBe('step_1')+ })++ it('CLAIM 6: UPDATE_TRIGGER changing input still bumps lastUpdatedDate', () => {+ const flowVersion = createFlowVersion()+ const updated = applyTriggerUpdate(flowVersion, {+ settings: { ...getTrigger(flowVersion).settings, input: { cronExpression: '0 * * * *' } },+ })+ expect(updated.lastUpdatedDate).not.toBe(TRIGGER_LAST_UPDATED)+ })++ it('CLAIM 7: UPDATE_TRIGGER replacing the piece bumps lastUpdatedDate', () => {+ const flowVersion = createFlowVersion()+ const updated = applyTriggerUpdate(flowVersion, {+ settings: { ...getTrigger(flowVersion).settings, pieceName: 'webhook', triggerName: 'catch_webhook' },+ })+ expect(updated.lastUpdatedDate).not.toBe(TRIGGER_LAST_UPDATED)+ })++ it('CLAIM 8: UPDATE_ACTION rename with form-normalized empty option objects is still rename-only', () => {+ const flowVersion = createFlowVersion()+ const updated = applyActionUpdate(flowVersion, {+ displayName: 'Get Renamed',+ settings: {+ ...getAction(flowVersion).settings,+ errorHandlingOptions: { continueOnFailure: {}, retryOnFailure: {} },+ },+ })+ expect(updated.lastUpdatedDate).toBe(ACTION_LAST_UPDATED)+ expect(updated.settings.sampleData?.sampleDataFileId).toBe(ACTION_SAMPLE_FILE_ID)+ })++ it('CLAIM 9: UPDATE_ACTION adding an empty-object input value bumps lastUpdatedDate', () => {+ const flowVersion = createFlowVersion()+ const action = getAction(flowVersion)+ const updated = applyActionUpdate(flowVersion, {+ settings: { ...action.settings, input: { ...action.settings.input, filters: {} } },+ })+ expect(updated.lastUpdatedDate).not.toBe(ACTION_LAST_UPDATED)+ })+})diff --git a/packages/core/utils/package.json b/packages/core/utils/package.jsonindex 3260ab00024..f0d13a09580 100644--- a/packages/core/utils/package.json+++ b/packages/core/utils/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/core-utils",- "version": "0.10.0",+ "version": "0.10.1","type": "commonjs","main": "./dist/src/index.js","scripts": {diff --git a/packages/core/utils/src/lib/object-utils.ts b/packages/core/utils/src/lib/object-utils.tsindex 88cfd545870..4deb2cda2fc 100644--- a/packages/core/utils/src/lib/object-utils.ts+++ b/packages/core/utils/src/lib/object-utils.ts@@ -121,6 +121,44 @@ export const isObject = (obj: unknown): obj is Record<string, unknown> => {return typeof obj === 'object' && obj !== null && !Array.isArray(obj)}+export function prune(value: unknown): unknown {+ if (Array.isArray(value)) {+ return value.map(prune)+ }+ if (typeof value === 'object' && value !== null) {+ const prunedEntries = Object.entries(value)+ .map(([key, entryValue]) => [key, prune(entryValue)] as const)+ .filter(([, entryValue]) => entryValue !== undefined)+ if (prunedEntries.length === 0) {+ return undefined+ }+ return Object.fromEntries(prunedEntries)+ }+ return value+}++export function deepEquals({ a, b }: DeepEqualsParams): boolean {+ if (a === b) {+ return true+ }+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {+ return false+ }+ if (Array.isArray(a) || Array.isArray(b)) {+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => deepEquals({ a: item, b: b[index] }))+ }+ const aRecord: Record<string, unknown> = { ...a }+ const bRecord: Record<string, unknown> = { ...b }+ const aKeys = Object.keys(aRecord)+ const bKeys = Object.keys(bRecord)+ return aKeys.length === bKeys.length && aKeys.every((key) => deepEquals({ a: aRecord[key], b: bRecord[key] }))+}++type DeepEqualsParams = {+ a: unknown+ b: unknown+}+export function groupBy<T, K extends string | number | symbol>(items: T[],keySelector: (item: T) => K,