Azure / Azure/azure-functions-durable-python

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

Aperta
#572 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug fixed-in-v2 P2
Lingua principale
Python
Stelle
157
Fork
70
Merge medio
2g 10h
PR unite (30g)
2

Descrizione

🐛 **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")

```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia tracciando azure.functions._durable_functions._serialize_custom_object e _deserialize_custom_object usando l'esempio Pydantic Generic nell'issue. Riproduci il flusso da activity a orchestrator e verifica come viene serializzato e cercato il nome della classe generica. Il lavoro è completato quando l'esempio viene deserializzato correttamente senza AttributeError né un errore di workflow non deterministico.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.