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): filter connectionExternalIds on the published version when versionState is LOCKED (#16856)
Abdulfff2a3e69abf
diff --git a/packages/server/api/src/app/flows/flow/flow.service.ts b/packages/server/api/src/app/flows/flow/flow.service.tsindex 9673b76f4a7..1605086b1c2 100644--- a/packages/server/api/src/app/flows/flow/flow.service.ts+++ b/packages/server/api/src/app/flows/flow/flow.service.ts@@ -202,7 +202,8 @@ export const flowService = (log: FastifyBaseLogger) => ({}if (connectionExternalIds !== undefined) {- queryBuilder.andWhere('latest_version."connectionIds" && :connectionExternalIds', { connectionExternalIds })+ const filteredVersion = versionState === FlowVersionState.DRAFT ? 'latest_version' : 'published_version'+ queryBuilder.andWhere(`${filteredVersion}."connectionIds" && :connectionExternalIds`, { connectionExternalIds })}if (agentExternalIds !== undefined) {diff --git a/packages/server/api/test/integration/ce/flows/flow/flow.test.ts b/packages/server/api/test/integration/ce/flows/flow/flow.test.tsindex cca12cdf642..7a487c60c17 100644--- a/packages/server/api/test/integration/ce/flows/flow/flow.test.ts+++ b/packages/server/api/test/integration/ce/flows/flow/flow.test.ts@@ -420,6 +420,42 @@ describe('Flow API', () => {})describe('List Flows endpoint', () => {+ it('Filters connections on the published version when versionState is LOCKED', async () => {+ const ctx = await createTestContext(app!)++ const mockFlow = createMockFlow({ projectId: ctx.project.id })+ await db.save('flow', mockFlow)+ const publishedVersion = createMockFlowVersion({+ flowId: mockFlow.id,+ state: FlowVersionState.LOCKED,+ created: '2020-01-01T00:00:00.000Z',+ connectionIds: ['published-only-connection'],+ })+ const newerDraftVersion = createMockFlowVersion({+ flowId: mockFlow.id,+ state: FlowVersionState.DRAFT,+ created: '2020-06-01T00:00:00.000Z',+ connectionIds: [],+ })+ await db.save('flow_version', [publishedVersion, newerDraftVersion])+ mockFlow.publishedVersionId = publishedVersion.id+ await db.save('flow', mockFlow)++ const draftMatches = await ctx.get('/v1/flows', {+ projectId: ctx.project.id,+ connectionExternalIds: 'published-only-connection',+ })+ const publishedMatches = await ctx.get('/v1/flows', {+ projectId: ctx.project.id,+ connectionExternalIds: 'published-only-connection',+ versionState: FlowVersionState.LOCKED,+ })++ expect(draftMatches?.json().data).toHaveLength(0)+ expect(publishedMatches?.statusCode).toBe(StatusCodes.OK)+ expect(publishedMatches?.json().data.map((flow: { id: string }) => flow.id)).toEqual([mockFlow.id])+ })+it('Filters Flows by status', async () => {const ctx = await createTestContext(app!)