Skip to content

Commit e5675e9

Browse files
committed
Fix: some validations error wasn't getting cath, we know catch them and reject message
1 parent 75a270a commit e5675e9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/aleph/db/accessors/messages.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,19 @@ def mark_pending_message_as_rejected(
468468
error_code = exception.error_code
469469
details = exception.details()
470470
exc_traceback = None
471+
472+
# Fix for ValueError in details - ensure all values are JSON serializable
473+
if details and "errors" in details:
474+
for error in details["errors"]:
475+
if (
476+
isinstance(error, dict)
477+
and "ctx" in error
478+
and isinstance(error["ctx"], dict)
479+
):
480+
for key, value in list(error["ctx"].items()):
481+
# Convert any ValueError or other exceptions to strings
482+
if isinstance(value, Exception):
483+
error["ctx"][key] = str(value)
471484
else:
472485
error_code = ErrorCode.INTERNAL_ERROR
473486
details = None

src/aleph/schemas/pending_messages.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import datetime as dt
2121
from typing import Any, Dict, Generic, Literal, Type
2222

23+
import pydantic_core
2324
from aleph_message.models import (
2425
AggregateContent,
2526
Chain,
@@ -190,5 +191,5 @@ def parse_message(message_dict: Any) -> BasePendingMessage:
190191

191192
try:
192193
return msg_cls(**message_dict)
193-
except ValidationError as e:
194+
except (ValidationError, pydantic_core.ValidationError) as e:
194195
raise InvalidMessageFormat(e.errors()) from e

0 commit comments

Comments
 (0)