Azure / Azure/azure-functions-durable-python

Serialization/Deserialization doesn't handle Generics and generates Non-deterministic workflow error

オープン
#572 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug fixed-in-v2 P2
主要言語
Python
スター
157
フォーク
70
平均マージ
2日 10時間
マージ済み PR(30日)
2

説明

🐛 **Describe the bug**
When a Pydantic Generic object is returned in an activity function `azure.functions._durable_functions._serialize_custom_object` returns "__class__": "ClassName[GenericSpecificClass]". When `azure.functions._durable_functions._deserialize_custom_object` is called in the calling orchestrator, getattr(module, "ClassName[GenericSpecificClass]") fails: ClassName exists but not the specialized "ClassName[GenericSpecificClass]".

🤔 **Expected behavior**
Serialization and deserialization handles Generics.

**Current behaviour**
Deserialization fails with `AttributeError: module 'xxx.xxx' has not attribute 'ClassName[GenericSpecificClass]'`and produces a Non-Deterministic Workflow error

☕ **Steps to reproduce**
```python
from pydantic import BaseModel
from typing import Generic
import azure.functions as func
import azure.durable_functions as df

class A(BaseModel, Generic[T]):
a: T

def to_json():
return self.model_dump(mode="json")

@classmethod
def from_json(cls, data: dict):
return cls(**data)

myApp = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)

@myApp.orchestration_trigger(context_name="context")
def orchestrator_function(context: df.DurableOrchestrationContext):
x = yield context.call_activity("hello", None)

@myApp.activity_trigger(input_name="params")
def hello(params):
return A[str](a="xxx")

```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、Issue の Pydantic Generic の例を使って azure.functions._durable_functions._serialize_custom_object と _deserialize_custom_object を追跡します。activity から orchestrator へのフローを再現し、ジェネリッククラス名がどのようにシリアライズされ、検索されるかを確認します。AttributeError や非決定的な workflow エラーが発生せずに例を正常にデシリアライズできれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。