Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/DurableTask.SqlServer/SqlUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@
DTUtils.TryDeserializeFailureDetails(rawOutput, out FailureDetails? failureDetails))
{
state.FailureDetails = failureDetails;

// Match the Azure Storage provider, which stores FailureDetails.ToString()
// ("{ErrorType}: {ErrorMessage}") as the output of failed orchestrations.
// Status APIs that only read Output would otherwise report no output.
state.Output = failureDetails!.ToString();
}
else
{
Expand Down Expand Up @@ -361,7 +366,7 @@
public static OrchestrationStatus GetRuntimeStatus(DbDataReader reader)
{
int ordinal = reader.GetOrdinal("RuntimeStatus");
return (OrchestrationStatus)Enum.Parse(typeof(OrchestrationStatus), GetStringOrNull(reader, ordinal));

Check warning on line 369 in src/DurableTask.SqlServer/SqlUtils.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'value' in 'object Enum.Parse(Type enumType, string value)'.
}

public static Guid? GetPayloadId(this DbDataReader reader)
Expand Down Expand Up @@ -391,8 +396,8 @@
{
return historyEvent.EventType switch
{
EventType.SubOrchestrationInstanceFailed => ((SubOrchestrationInstanceFailedEvent)historyEvent).Reason,

Check warning on line 399 in src/DurableTask.SqlServer/SqlUtils.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'x' in 'SqlString.implicit operator SqlString(string x)'.
EventType.TaskFailed => ((TaskFailedEvent)historyEvent).Reason,

Check warning on line 400 in src/DurableTask.SqlServer/SqlUtils.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'x' in 'SqlString.implicit operator SqlString(string x)'.
_ => SqlString.Null,
};
}
Expand Down Expand Up @@ -934,7 +939,7 @@
string? instanceId = null,
CancellationToken cancellationToken = default)
{
return ExecuteSprocAndTraceAsync(

Check warning on line 942 in src/DurableTask.SqlServer/SqlUtils.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in value of type 'Task<object?>' doesn't match target type 'Task<object>'.
command,
traceHelper,
instanceId,
Expand Down Expand Up @@ -1028,7 +1033,7 @@
try
{
// Open connection if network blip caused it to close on a previous attempt
if (command.Connection.State != ConnectionState.Open)

Check warning on line 1036 in src/DurableTask.SqlServer/SqlUtils.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
await command.Connection.OpenAsync();
}
Expand Down
14 changes: 14 additions & 0 deletions test/DurableTask.SqlServer.Tests/Integration/Orchestrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,19 @@ public async Task UncaughtOrchestrationException()
Assert.Equal(exceptionToThrow.Message, state.FailureDetails.ErrorMessage);
Assert.Equal(exceptionToThrow.GetType().FullName, state.FailureDetails.ErrorType);
Assert.NotNull(state.FailureDetails.StackTrace);

// Like the Azure Storage provider, the output of a failed orchestration is "{ErrorType}: {ErrorMessage}"
string expectedOutput = $"{exceptionToThrow.GetType().FullName}: {exceptionToThrow.Message}";
Assert.Equal(expectedOutput, state.Output);

// The paged query path must report the same output and failure details
var query = new SqlOrchestrationQuery { InstanceIdPrefix = instance.InstanceId, FetchOutput = true };
IReadOnlyCollection<OrchestrationState> results =
await this.testService.OrchestrationServiceMock.Object.GetManyOrchestrationsAsync(query, CancellationToken.None);
OrchestrationState queriedState = Assert.Single(results);
Assert.Equal(OrchestrationStatus.Failed, queriedState.OrchestrationStatus);
Assert.Equal(expectedOutput, queriedState.Output);
Assert.Equal(state.FailureDetails, queriedState.FailureDetails);
}

[Fact]
Expand All @@ -303,6 +316,7 @@ public async Task UncaughtActivityException()
Assert.Contains("Task 'Throw' (#0) failed with an unhandled exception", state.FailureDetails.ErrorMessage);
Assert.Equal(typeof(TaskFailedException).FullName, state.FailureDetails.ErrorType);
Assert.NotNull(state.FailureDetails.StackTrace);
Assert.Equal($"{state.FailureDetails.ErrorType}: {state.FailureDetails.ErrorMessage}", state.Output);

// Ideally, the original exception message would be included in the orchestrator output.
// This would require a change in DurableTask.Core.
Expand Down
Loading