Skip to content

fix: close the batch cleanly when Run Modules returns no result set - #59

Merged
RoelantVos merged 1 commit into
mainfrom
fix/empty-module-resultset
Nov 15, 2026
Merged

RoelantVos merged 1 commit into
mainfrom
fix/empty-module-resultset

Conversation

@RoelantVos

Copy link
Copy Markdown
Collaborator

Requested by Roelant · project thread

What

A Fabric Script activity drops a result set that holds no rows. When no module proceeds — an aborted or cancelled batch evaluation, or a batch opened while no modules are registered yet (for example mid-redeploy) — Run Modules produces an empty resultSets array, and the Close Batch / Close Module activities crashed on:

The expression 'string(activity('Run Modules').output.resultSets[0].rows)' cannot be evaluated
because array index '0' cannot be selected from empty array.

The crash leaves the Batch Instance open as Executing, which makes every following run of the same batch evaluate to Abort — which again yields zero modules and the same crash, masking the real state.

Fix

The ModuleResults expression in both pipelines now reports an empty JSON array when resultSetCount is 0:

@string(if(equals(coalesce(activity('Run Modules').output.resultSetCount, 0), 0), json('[]'), activity('Run Modules').output.resultSets[0].rows))

close-batch.sql and close-module.sql already handle an empty result list correctly (the batch closes from the instance statuses; a module with no reported result closes as Failure with a clear event detail), so no SQL changes are needed.

Changed in fabric/templates/DIRECT Run Batch.template.json and DIRECT Run Module.template.json, with the generated fabric/items/*/pipeline-content.json updated to match (same one-line substitution as Build-PipelineDefinitions.ps1 produces).

Verified

Reproduced and diagnosed on a live workspace (pipeline run activity output shows resultSetCount: 0 for the empty case). The patched expression was applied to the deployed pipelines of that workspace and a full b_DV batch run completed green: 51 modules Succeeded, all layers loaded.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@RoelantVos RoelantVos self-assigned this Nov 15, 2026
@RoelantVos
RoelantVos merged commit c765e05 into main Nov 15, 2026
3 checks passed
@RoelantVos RoelantVos mentioned this pull request Nov 15, 2026
RoelantVos added a commit that referenced this pull request Nov 15, 2026
Version bump for the empty-module-resultset pipeline fix (#59): the
release workflow publishes v2.2.4 on merge to main.

Co-authored-by: Roelant Vos <roelantvos@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant