Skip to content

Commit 7943edf

Browse files
authored
Fix step execution error when output is undefined (#756)
Fixes OPS-1925. Tested cases - Return undefined; - Return an empty string; - Return 0; - Return null;
1 parent 160c9ac commit 7943edf

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/server/api/src/app/flows/step-test-output/flow-step-test-output.service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export const flowStepTestOutputService = {
2020
flowVersionId,
2121
output,
2222
}: SaveParams): Promise<FlowStepTestOutput> {
23-
const compressedOutput = await encryptAndCompress(output);
23+
let compressedOutput = Buffer.alloc(0);
24+
if (output !== undefined) {
25+
compressedOutput = await encryptAndCompress(output);
26+
}
2427

2528
const existing = await flowStepTestOutputRepo().findOneBy({
2629
stepId,
@@ -85,7 +88,14 @@ export const flowStepTestOutputService = {
8588
async function decompressOutput(
8689
record: FlowStepTestOutput,
8790
): Promise<FlowStepTestOutput> {
88-
const decryptedOutput = await decompressAndDecrypt(record.output as Buffer);
91+
const outputBuffer = record.output as Buffer;
92+
if (outputBuffer.length === 0) {
93+
return {
94+
...record,
95+
output: undefined,
96+
};
97+
}
98+
const decryptedOutput = await decompressAndDecrypt(outputBuffer);
8999

90100
return {
91101
...record,

0 commit comments

Comments
 (0)