microsoft / microsoft/durabletask-java
Only the innermost exception is returned when activity functions throw
未關閉
還沒有人認領這個 Issue。
P2
- 主要語言
- Java
- 星號
- 29
- 分支
- 18
- 平均合併
- 1 天 10 小時
- 30 天內合併 PR
- 2
描述
When an activity function throws an exception, we return a FailureDetails but it only represents the innermost exception. Request changing this behavior to match the other durable language implementations returning the outermost user error and all inner errors recursively.
Repro code:
@FunctionName("CustomRetryActivityFunction")
public String customRetryActivityFunction(
@DurableOrchestrationTrigger(name = "ctx") TaskOrchestrationContext ctx) {
TaskOptions options = new TaskOptions(retryContext -> {
FailureDetails lastFailure = retryContext.getLastFailure();
if (lastFailure != null
// BUG: Only the innermost failure is available in the Java SDK
// BUG: isCausedBy() relies on Class.forName() but we do not provide the fully qualified class name
// in the FailureDetails
&& lastFailure.getErrorType().equals("OverflowException")
// && lastFailure.isCausedBy(InvalidOperationException.class)
// BUG: We do not implement inner failures in the Java SDK yet
// && lastFailure.getInnerFailure() != null
// && lastFailure.getInnerFailure().isCausedBy("java.lang.OverflowException")
&& retryContext.getLastAttemptNumber() < 3) {
return true;
}
return false;
});
return ctx.callActivity("RaiseComplexException", ctx.getInstanceId(), options, String.class).await();
}
@FunctionName("RaiseComplexException")
public String raiseComplexException(
@DurableActivityTrigger(name = "instanceId") String instanceId,
final ExecutionContext context) throws InvalidOperationException {
AtomicInteger count = globalRetryCount.computeIfAbsent(instanceId, k -> new AtomicInteger(0));
int current = count.incrementAndGet();
if (current == 1) {
OverflowException inner = new OverflowException("Inner exception message");
InvalidOperationException ex = new InvalidOperationException(
"This activity failed\r\nMore information about the failure", inner);
throw ex;
} else {
return "Success";
}
}
Result:
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先追蹤 activity-function 失敗時回傳的 FailureDetails,以及 retryContext.getLastFailure() 如何公開這些資訊。將 Java SDK 的行為與 issue 中提到的其他 Durable 語言實作進行比較。當最外層的使用者錯誤、其完整限定型別,以及所有巢狀的內部錯誤都可以遞迴檢查時,即視為完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100