Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are 2 errors. #2

Open
Allin2000 opened this issue Dec 10, 2024 · 4 comments
Open

There are 2 errors. #2

Allin2000 opened this issue Dec 10, 2024 · 4 comments

Comments

@Allin2000
Copy link

api:get_global_article_feed (correct:article_service.get_articles_by_filters, wrong:correct:article_service.get_articles_by_filters_v2)
datetime.UTC

python3.10

@borys25ol
Copy link
Owner

@Allin2000
Could you provide more details, please? What exactly is wrong?

@Allin2000
Copy link
Author

INFO: 127.0.0.1:41506 - "GET /api/articles/feed?limit=20&offset=0 HTTP/1.1" 200 OK
INFO: 127.0.0.1:51280 - "GET /api/articles?limit=20&offset=0 HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last):
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_utils.py", line 76, in collapse_excgroups
    | yield
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 186, in call
    | async with anyio.create_task_group() as task_group:
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 815, in aexit
    | raise BaseExceptionGroup(
    | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 406, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
    | return await self.app(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/applications.py", line 113, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in call
    | raise exc
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in call
    | await self.app(scope, receive, _send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 185, in call
    | with collapse_excgroups():
    | File "/usr/lib/python3.10/contextlib.py", line 153, in exit
    | self.gen.throw(typ, value, traceback)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
    | raise exc
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 187, in call
    | response = await self.dispatch_func(request, call_next)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/middlewares.py", line 44, in dispatch
    | response = await call_next(request)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 163, in call_next
    | raise app_exc
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 149, in coro
    | await self.app(scope, receive_or_disconnect, send_no_error)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in call
    | await self.app(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 715, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 735, in app
    | await route.handle(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
    | await self.app(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
    | response = await f(request)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
    | raw_response = await run_endpoint_function(
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
    | return await dependant.call(**values)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/routes/article.py", line 59, in get_global_article_feed
    | return ArticlesFeedResponse.from_dto(dto=articles_feed_dto)
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/schemas/responses/article.py", line 64, in from_dto
    | articles = [
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/schemas/responses/article.py", line 65, in
    | ArticleResponse.from_dto(dto=article_dto).article
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/schemas/responses/article.py", line 38, in from_dto
    | article = ArticleData(
    | File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/pydantic/main.py", line 212, in init
    | validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
    | pydantic_core._pydantic_core.ValidationError: 1 validation error for ArticleData
    | tagList
    | Input should be a valid list [type=list_type, input_value='string', input_type=str]
    | For further information visit https://errors.pydantic.dev/2.9/v/list_type
    +------------------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 406, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/applications.py", line 113, in call
await self.middleware_stack(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 185, in call
with collapse_excgroups():
File "/usr/lib/python3.10/contextlib.py", line 153, in exit
self.gen.throw(typ, value, traceback)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
raise exc
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 187, in call
response = await self.dispatch_func(request, call_next)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/middlewares.py", line 44, in dispatch
response = await call_next(request)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 163, in call_next
raise app_exc
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in call
await self.app(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 715, in call
await self.middleware_stack(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 735, in app
await route.handle(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/routes/article.py", line 59, in get_global_article_feed
return ArticlesFeedResponse.from_dto(dto=articles_feed_dto)
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/schemas/responses/article.py", line 64, in from_dto
articles = [
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/schemas/responses/article.py", line 65, in
ArticleResponse.from_dto(dto=article_dto).article
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/conduit/api/schemas/responses/article.py", line 38, in from_dto
article = ArticleData(
File "/root/realworld_fastapi_vue3/fastapi-realworld-backend/.venv/lib/python3.10/site-packages/pydantic/main.py", line 212, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for ArticleData
tagList
Input should be a valid list [type=list_type, input_value='string', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/list_type

@Allin2000
Copy link
Author

async def _get_article_info(
self,
session: AsyncSession,
article: ArticleRecordDTO,
profile: ProfileDTO,
user_id: int | None = None,
) -> ArticleDTO:

###########Here
    article_tags = [
        tag.tag
        for tag in await self._article_tag_repo.list(
            session=session, article_id=article.id
        )
    ]
    favorites_count = await self._favorite_repo.count(
        session=session, article_id=article.id
    )
    is_favorited_by_user = (
        await self._favorite_repo.exists(
            session=session, author_id=user_id, article_id=article.id
        )
        if user_id
        else False
    )
    return ArticleDTO(
        **asdict(article),
        author=ArticleAuthorDTO(
            username=profile.username,
            bio=profile.bio,
            image=profile.image,
            following=profile.following,
        ),
        tags=article_tags,
        favorited=is_favorited_by_user,
        favorites_count=favorites_count,
    )

@borys25ol
Copy link
Owner

borys25ol commented Dec 11, 2024

@Allin2000
Thank you for your feedback. I’ve resolved the issue with the tags list in the global articles feed.

Additionally, please ensure you’re using Python 3.12 as mentioned in the “Prerequisites” section of the README file.
This project has not been tested with Python 3.10.

Let me know if everything is working correctly after the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants