Azure / Azure/azure-functions-durable-python
Serialization/Deserialization doesn't handle Generics and generates Non-deterministic workflow error
- Lenguaje dominante
- Python
- Estrellas
- 157
- Forks
- 70
- Merge medio
- 2 d 10 h
- PR fusionados (30 d)
- 2
Descripción
🐛 **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")
```
Guía de contribución
Línea de trabajo
Empieza rastreando azure.functions._durable_functions._serialize_custom_object y _deserialize_custom_object usando el ejemplo de Pydantic Generic del issue. Reproduce el flujo de actividad a orquestador e inspecciona cómo se serializa y se busca el nombre de la clase genérica. Se considera terminado cuando el ejemplo se deserializa correctamente sin AttributeError ni un error de workflow no determinista.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100