Skip to content

Commit dbf13b5

Browse files
author
Roman Snapko
committed
fix: pr comments
1 parent 641ffdc commit dbf13b5

2 files changed

Lines changed: 57 additions & 2 deletions

File tree

packages/server/api/test/unit/ai/context-enrichment.service.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,63 @@ describe('ContextEnrichmentService', () => {
294294
});
295295
});
296296

297+
it("should set an error value when step isn't found (getStepById returns undefined)", async () => {
298+
const mockFlow = {
299+
version: {
300+
trigger: { id: 'trigger-id' },
301+
},
302+
} as PopulatedFlow;
303+
304+
const mockInputContext = {
305+
flowId: mockFlowId,
306+
flowVersionId: mockFlowVersionId,
307+
steps: [
308+
{
309+
id: 'step-unknown',
310+
variables: [
311+
{
312+
name: 'variable1',
313+
value: '{{some.expression}}',
314+
},
315+
],
316+
},
317+
],
318+
};
319+
320+
mockFlowService.getOnePopulatedOrThrow.mockResolvedValue(mockFlow);
321+
mockAccessTokenManager.generateEngineToken.mockResolvedValue(
322+
mockEngineToken,
323+
);
324+
mockFlowHelper.getAllStepIds.mockReturnValue(['step-unknown']);
325+
mockFlowHelper.getStepById.mockReturnValue(undefined);
326+
mockFlowStepTestOutputService.listEncrypted.mockResolvedValue([]);
327+
mockGroupStepOutputsById.mockReturnValue({});
328+
329+
const result = await enrichContext(mockInputContext, mockProjectId);
330+
331+
expect(result).toEqual({
332+
flowId: mockFlowId,
333+
flowVersionId: mockFlowVersionId,
334+
currentStepId: undefined,
335+
currentStepData: '',
336+
steps: [
337+
{
338+
id: 'step-unknown',
339+
variables: [
340+
{
341+
name: 'variable1',
342+
value:
343+
'Failed to resolve variable: Step not found in the workflow.',
344+
},
345+
],
346+
},
347+
],
348+
});
349+
350+
// Ensure engine is not called when step cannot be found
351+
expect(mockEngineRunner.executeVariable).not.toHaveBeenCalled();
352+
});
353+
297354
it('should handle engine runner exceptions', async () => {
298355
const mockFlow = {
299356
version: {

packages/shared/src/lib/ai/chat/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ export const ChatFlowContext = Type.Object({
5252
flowVersionId: Type.String(),
5353
runId: Type.Optional(Type.String()),
5454
currentStepId: Type.Optional(Type.String()),
55-
currentStepDisplayName: Type.Optional(Type.String()),
56-
currentStepIndex: Type.Optional(Type.Number()),
5755
currentStepData: Type.Optional(Type.Any()),
5856
steps: Type.Array(StepContext),
5957
});

0 commit comments

Comments
 (0)