Skip to content

Commit 1863138

Browse files
committed
Merge remote-tracking branch 'origin/feat/activity-call-stack' into feat/activity-call-stack
2 parents 1a65506 + fc34a31 commit 1863138

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

  • src/modules/Elsa.Workflows.Api/Endpoints/ActivityExecutions/GetCallStack

src/modules/Elsa.Workflows.Api/Endpoints/ActivityExecutions/GetCallStack/Endpoint.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,29 @@ public override async Task HandleAsync(Request request, CancellationToken cancel
2424
{
2525
var id = Route<string>("id");
2626
var includeCrossWorkflowChain = request.IncludeCrossWorkflowChain ?? true;
27+
28+
// Apply defaulting and upper bound to the requested page size to prevent excessive queries.
29+
const int defaultTake = 100;
30+
const int maxTake = 1000;
31+
2732
var skip = request.Skip;
28-
var take = request.Take;
33+
var take = request.Take ?? defaultTake;
2934

30-
var result = await store.GetExecutionChainAsync(id, includeCrossWorkflowChain, skip, take, cancellationToken);
35+
if (take <= 0)
36+
take = defaultTake;
3137

32-
if (result.TotalCount == 0)
38+
if (take > maxTake)
39+
take = maxTake;
40+
// First, check if the activity execution exists.
41+
var activityExecution = await store.FindAsync(id, cancellationToken);
42+
if (activityExecution == null)
3343
{
3444
await Send.NotFoundAsync(cancellationToken);
3545
return;
3646
}
3747

48+
// Then, get the execution chain. An empty chain should result in 200 with an empty items array.
49+
var result = await store.GetExecutionChainAsync(id, includeCrossWorkflowChain, skip, take, cancellationToken);
3850
var response = new Response
3951
{
4052
ActivityExecutionId = id,

0 commit comments

Comments
 (0)