From ccea5835d65e08e5af5c5eff7ee90bd5f813448a Mon Sep 17 00:00:00 2001 From: Roelant Vos Date: Sun, 15 Nov 2026 18:04:34 +0100 Subject: [PATCH] fix: close the batch cleanly when Run Modules returns no result set A Fabric Script activity drops a result set that holds no rows, so a run in which no module proceeds (an aborted or cancelled evaluation, or a batch opened while no modules are registered yet) leaves activity('Run Modules').output.resultSets empty. The Close Batch and Close Module activities indexed resultSets[0] unconditionally, crashed, and left the Batch Instance open as 'Executing', which aborts every following run of the same batch. The ModuleResults expression now reports an empty JSON array when resultSetCount is 0; close-batch.sql and close-module.sql already close the instances correctly for an empty result list. Co-Authored-By: Claude Fable 5 --- .../items/DIRECT Run Batch.DataPipeline/pipeline-content.json | 2 +- .../items/DIRECT Run Module.DataPipeline/pipeline-content.json | 2 +- fabric/templates/DIRECT Run Batch.template.json | 2 +- fabric/templates/DIRECT Run Module.template.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fabric/items/DIRECT Run Batch.DataPipeline/pipeline-content.json b/fabric/items/DIRECT Run Batch.DataPipeline/pipeline-content.json index 75595a7..959ed51 100644 --- a/fabric/items/DIRECT Run Batch.DataPipeline/pipeline-content.json +++ b/fabric/items/DIRECT Run Batch.DataPipeline/pipeline-content.json @@ -348,7 +348,7 @@ "size": "-1", "direction": "Input", "value": { - "value": "@string(activity('Run Modules').output.resultSets[0].rows)", + "value": "@string(if(equals(coalesce(activity('Run Modules').output.resultSetCount, 0), 0), json('[]'), activity('Run Modules').output.resultSets[0].rows))", "type": "Expression" } }, diff --git a/fabric/items/DIRECT Run Module.DataPipeline/pipeline-content.json b/fabric/items/DIRECT Run Module.DataPipeline/pipeline-content.json index 352c450..721d8d9 100644 --- a/fabric/items/DIRECT Run Module.DataPipeline/pipeline-content.json +++ b/fabric/items/DIRECT Run Module.DataPipeline/pipeline-content.json @@ -334,7 +334,7 @@ "size": "-1", "direction": "Input", "value": { - "value": "@string(activity('Run Modules').output.resultSets[0].rows)", + "value": "@string(if(equals(coalesce(activity('Run Modules').output.resultSetCount, 0), 0), json('[]'), activity('Run Modules').output.resultSets[0].rows))", "type": "Expression" } } diff --git a/fabric/templates/DIRECT Run Batch.template.json b/fabric/templates/DIRECT Run Batch.template.json index fc64eef..7e835bb 100644 --- a/fabric/templates/DIRECT Run Batch.template.json +++ b/fabric/templates/DIRECT Run Batch.template.json @@ -348,7 +348,7 @@ "size": "-1", "direction": "Input", "value": { - "value": "@string(activity('Run Modules').output.resultSets[0].rows)", + "value": "@string(if(equals(coalesce(activity('Run Modules').output.resultSetCount, 0), 0), json('[]'), activity('Run Modules').output.resultSets[0].rows))", "type": "Expression" } }, diff --git a/fabric/templates/DIRECT Run Module.template.json b/fabric/templates/DIRECT Run Module.template.json index c8c81f4..6283c87 100644 --- a/fabric/templates/DIRECT Run Module.template.json +++ b/fabric/templates/DIRECT Run Module.template.json @@ -334,7 +334,7 @@ "size": "-1", "direction": "Input", "value": { - "value": "@string(activity('Run Modules').output.resultSets[0].rows)", + "value": "@string(if(equals(coalesce(activity('Run Modules').output.resultSetCount, 0), 0), json('[]'), activity('Run Modules').output.resultSets[0].rows))", "type": "Expression" } }