Custom object serialization broken for orchestrator return values
@andystaples đang làm issue này rồi.
Từ ngày 31/7/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Bắt đầu tại azure/durable_functions/models/TaskOrchestrationExecutor.py, ở TaskOrchestrationExecutor.get_orchestrator_state_str(), và so sánh việc tuần tự hóa JSON của nó với các model hoặc entity khác được đề cập trong issue. Tái hiện orchestration bằng cách sử dụng ví dụ CustomResult và xác minh rằng có thể trả về một object có to_json() mà không gặp lỗi not-serializable.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🐛 Describe the bug
Azure Durable Functions Python SDK fails to serialize custom objects that implement a to_json() method when returning from orchestrator functions. The error "Object of type [CustomClass] is not JSON serializable" is raised.
🤔 Expected behavior
Custom objects implementing a to_json() method should be automatically serialized when returned from orchestrator functions.
☕ Steps to reproduce
Basic orchestration with custom return types.
- Create a custom class with
to_json()andfrom_json()methods:
from dataclasses import dataclass
import azure.durable_functions as df
import azure.functions as func
app = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@dataclass
class CustomResult():
message: str
success: bool = True
def to_json(self):
return {"message": self.message, "success": self.success}
@classmethod
def from_json(cls, data):
return cls(message=data["message"], success=data["success"])
@app.orchestration_trigger(context_name="context")
def orchestrator_function(context: df.DurableOrchestrationContext):
return CustomResult(message="Hello from orchestrator!", success=True)
@app.route(route="test", methods=["GET"])
@app.durable_client_input(client_name="client")
async def http_start_conversion(req: func.HttpRequest, client: df.DurableOrchestrationClient) -> func.HttpResponse:
instance_id = await client.start_new(
orchestration_function_name="orchestrator_function"
)
return client.create_check_status_response(req, instance_id)
- Execute the orchestration - it will fail with "Object of type CustomResult is not JSON serializable"
Environment: Running locally with
Azure Functions Core Tools Version: 4.1.0
azure-functions-durable: 1.3.2
Root cause: In TaskOrchestrationExecutor.get_orchestrator_state_str(), the code calls dumps without a default argument:
https://github.com/Azure/azure-functions-durable-python/blob/15ed958555b9410629f97cd7884d8783cb0e460e/azure/durable_functions/models/TaskOrchestrationExecutor.py#L284
But should call:
json.dumps(self._data, default=_serialize_custom_object) as in other models or entities.
⚡If deployed to Azure
Didn't test yet. Since the bug is in the Python SDK code itself, I expect the same issue to occur.
- Ngôn ngữ chính
- Python
- Star
- 157
- Fork
- 70
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/azure-functions-durable-python
-
Enhancement fixed-in-v2 P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Azure/azure-functions-durable-python#617 · 1 bình luận ·
-
bug Debuggability fixed-in-v2 P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Azure/azure-functions-durable-python#587 · 2 bình luận · 1 reaction ·
-
bug fixed-in-v2 P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Azure/azure-functions-durable-python#475 · 1 bình luận ·
-
Enhancement fixed-in-v2 P3
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
Azure/azure-functions-durable-python#618 · 1 bình luận ·
-
blocked bug fixed-in-v2 known-regression
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Azure/azure-functions-durable-python#600 · 3 bình luận ·
Tất cả issue của Azure/azure-functions-durable-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
rpm-software-management/mock#1824 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
jpata/particleflow#520 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue hacktoberfest
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
gridhead/gi-loadouts#699 ·
Maintainer thường phản hồi trong vòng 13 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
FinanceFlash/unvibecode#206 ·
Maintainer thường phản hồi trong vòng 1 ngày