Skip to content

Commit d8f0a66

Browse files
author
Andres D. Molins
committed
Fix: Seems that with POST messages without item_type, the content is not well set. I have applied a fix to allow modifying and set it.
1 parent 703fa45 commit d8f0a66

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/aleph/schemas/pending_messages.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ class BasePendingMessage(AlephBaseMessage, Generic[MType, ContentType]):
112112

113113
@model_validator(mode="before")
114114
def load_content(cls, values):
115-
return base_pending_message_load_content(values)
115+
values_copy = values.copy()
116+
return base_pending_message_load_content(values_copy)
116117

117118
@field_validator("time", mode="before")
118119
def check_time(cls, v, info):

src/aleph/web/controllers/accounts.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from aiohttp import web
66
from aleph_message.models import MessageType
7-
from pydantic import ValidationError
7+
from pydantic import ValidationError, TypeAdapter
88

99
import aleph.toolkit.json as aleph_json
1010
from aleph.db.accessors.balances import (
@@ -151,13 +151,11 @@ async def get_account_files(request: web.Request) -> web.Response:
151151
if not file_pins:
152152
raise web.HTTPNotFound()
153153

154+
adapter = TypeAdapter(list[GetAccountFilesResponseItem])
154155
response = GetAccountFilesResponse(
155156
address=address,
156157
total_size=total_size,
157-
files=[
158-
GetAccountFilesResponseItem.model_validate(dict(file_pin))
159-
for file_pin in file_pins
160-
],
158+
files=adapter.validate_python(file_pins),
161159
pagination_page=query_params.page,
162160
pagination_total=nb_files,
163161
pagination_per_page=query_params.pagination,

0 commit comments

Comments
 (0)