Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/aleph/db/accessors/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,19 @@ def mark_pending_message_as_rejected(
error_code = exception.error_code
details = exception.details()
exc_traceback = None

# Fix for ValueError in details - ensure all values are JSON serializable
if details and "errors" in details:
for error in details["errors"]:
if (
isinstance(error, dict)
and "ctx" in error
and isinstance(error["ctx"], dict)
):
for key, value in list(error["ctx"].items()):
# Convert any ValueError or other exceptions to strings
if isinstance(value, Exception):
error["ctx"][key] = str(value)
else:
error_code = ErrorCode.INTERNAL_ERROR
details = None
Expand Down
3 changes: 2 additions & 1 deletion src/aleph/schemas/pending_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import datetime as dt
from typing import Any, Dict, Generic, Literal, Type

import pydantic_core
from aleph_message.models import (
AggregateContent,
Chain,
Expand Down Expand Up @@ -190,5 +191,5 @@ def parse_message(message_dict: Any) -> BasePendingMessage:

try:
return msg_cls(**message_dict)
except ValidationError as e:
except (ValidationError, pydantic_core.ValidationError) as e:
raise InvalidMessageFormat(e.errors()) from e
Loading