Skip to content

Commit f750cad

Browse files
committed
Add diag logging to findout CI test failure.
1 parent 5beb041 commit f750cad

3 files changed

Lines changed: 62 additions & 9 deletions

File tree

dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/06_WorkflowSharedState/Executors.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ public override async ValueTask<OrderDetails> HandleAsync(
3838
string message,
3939
IWorkflowContext context,
4040
CancellationToken cancellationToken = default)
41+
{
42+
try
43+
{
44+
return await HandleAsyncCore(message, context, cancellationToken);
45+
}
46+
catch (Exception ex)
47+
{
48+
Console.Error.WriteLine($"[DIAG] ValidateOrder.HandleAsync failed: {ex.GetType().FullName}: {ex.Message}");
49+
Console.Error.WriteLine($"[DIAG] StackTrace: {ex.StackTrace}");
50+
throw;
51+
}
52+
}
53+
54+
private async ValueTask<OrderDetails> HandleAsyncCore(
55+
string message,
56+
IWorkflowContext context,
57+
CancellationToken cancellationToken = default)
4158
{
4259
await Task.Delay(TimeSpan.FromMilliseconds(200), cancellationToken);
4360

dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableActivityExecutor.cs

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,46 @@ internal static async Task<string> ExecuteAsync(
4646
object typedInput = DeserializeInput(executorInput, inputType);
4747

4848
DurableWorkflowContext workflowContext = new(sharedState, executor);
49-
object? result = await executor.ExecuteCoreAsync(
50-
typedInput,
51-
new TypeId(inputType),
52-
workflowContext,
53-
WorkflowTelemetryContext.Disabled,
54-
cancellationToken).ConfigureAwait(false);
55-
56-
return SerializeActivityOutput(result, workflowContext);
49+
50+
object? result;
51+
try
52+
{
53+
result = await executor.ExecuteCoreAsync(
54+
typedInput,
55+
new TypeId(inputType),
56+
workflowContext,
57+
WorkflowTelemetryContext.Disabled,
58+
cancellationToken).ConfigureAwait(false);
59+
}
60+
catch (Exception ex)
61+
{
62+
// Diagnostic logging to surface inner exception details in CI
63+
Console.Error.WriteLine($"[DIAG] DurableActivityExecutor: ExecuteCoreAsync failed for '{binding.Id}' (inputType={inputType.FullName})");
64+
Console.Error.WriteLine($"[DIAG] Exception: {ex.GetType().FullName}: {ex.Message}");
65+
for (Exception? inner = ex.InnerException; inner is not null; inner = inner.InnerException)
66+
{
67+
Console.Error.WriteLine($"[DIAG] Inner: {inner.GetType().FullName}: {inner.Message}");
68+
Console.Error.WriteLine($"[DIAG] StackTrace: {inner.StackTrace}");
69+
}
70+
71+
throw;
72+
}
73+
74+
string serialized;
75+
try
76+
{
77+
serialized = SerializeActivityOutput(result, workflowContext);
78+
}
79+
catch (Exception ex)
80+
{
81+
Console.Error.WriteLine($"[DIAG] DurableActivityExecutor: SerializeActivityOutput failed for '{binding.Id}'");
82+
Console.Error.WriteLine($"[DIAG] Result type: {result?.GetType().FullName ?? "null"}");
83+
Console.Error.WriteLine($"[DIAG] Exception: {ex.GetType().FullName}: {ex.Message}");
84+
Console.Error.WriteLine($"[DIAG] StackTrace: {ex.StackTrace}");
85+
throw;
86+
}
87+
88+
return serialized;
5789
}
5890

5991
private static string SerializeActivityOutput(object? result, DurableWorkflowContext context)

dotnet/src/Microsoft.Agents.AI.Workflows/Executor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ protected internal virtual ValueTask InitializeAsync(IWorkflowContext context, C
284284

285285
if (!result.IsSuccess)
286286
{
287-
throw new TargetInvocationException($"Error invoking handler for {message.GetType()}", result.Exception);
287+
// Include inner exception details for diagnostics (otherwise hidden by DTS FailureDetails)
288+
string innerDetails = result.Exception is not null
289+
? $" --> {result.Exception.GetType().Name}: {result.Exception.Message}"
290+
: string.Empty;
291+
throw new TargetInvocationException($"Error invoking handler for {message.GetType()}{innerDetails}", result.Exception);
288292
}
289293

290294
if (result.IsVoid)

0 commit comments

Comments
 (0)