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

[BUG] - deleted users recipes causing listing to error #4210

Closed
5 of 6 tasks
russell opened this issue Sep 15, 2024 · 7 comments
Closed
5 of 6 tasks

[BUG] - deleted users recipes causing listing to error #4210

russell opened this issue Sep 15, 2024 · 7 comments
Labels
bug Something isn't working triage

Comments

@russell
Copy link

russell commented Sep 15, 2024

First Check

  • This is not a feature request.
  • I added a very descriptive title to this issue (title field is above this).
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.
  • This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

500's when visiting the main recipe listing.

Steps to Reproduce

ok, i think it was caused by me deleting a user. In the past, i had been using regular users, but then i switched to oauth, when i did that for what ever reason (something went a bit awry) i deleted my user and recreated it.

I was able to fix my installation, by running an update against the recipes table to take ownership of the recipes

update recipes set user_id = '64760ef34c7c4fd7983a2a5689ea761d' where user_id = '61c6829d20504176a9948a09e47b4b97';

Please provide relevant logs

ERROR    2024-09-15T09:56:12 - Exception in ASGI application
Traceback (most recent call last):
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in __call__
    return await self.app(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 24, in __call__
    await responder(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 44, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 72, in app
    response = await func(request)
  File "/app/mealie/routes/_base/routers.py", line 35, in custom_route_handler
    response = await original_route_handler(request)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 214, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/app/mealie/routes/recipe/recipe_crud_routes.py", line 341, in get_all
    pagination_response = self.group_recipes.by_user(self.user.id).page_all(
  File "/app/mealie/repos/repository_recipes.py", line 222, in page_all
    items = [RecipeSummary.model_validate(item) for item in data]
  File "/app/mealie/repos/repository_recipes.py", line 222, in <listcomp>
    items = [RecipeSummary.model_validate(item) for item in data]
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/pydantic/main.py", line 593, in model_validate
    return cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 1 validation error for RecipeSummary
household_id
  UUID input should be a string, bytes or UUID object [type=uuid_type, input_value=None, input_type=NoneType]

Mealie Version

0eb3e3f

Deployment

Docker (Linux)

Additional Deployment Details

No response

@russell russell added bug Something isn't working triage labels Sep 15, 2024
@boc-the-git
Copy link
Collaborator

Please provide accurate version info, from the settings page.

@russell
Copy link
Author

russell commented Sep 16, 2024

I have updated the report with the sha

@boc-the-git
Copy link
Collaborator

@michael-genson is this a households bug? 2nd last line of the logs references household_id

@michael-genson
Copy link
Collaborator

This isn't a household bug exactly, looks like an issue with deleting users (as mentioned in the initial comment)

A recipe's household_id is proxied off its user's household_id, so if it has an invalid user attached it will have a null household id (and throw this error)

So TL;DR it's a broader issue with deleting users not being handled properly. Similar/same issue: #3171

@russell were you able to get this sorted for your instance?

@russell
Copy link
Author

russell commented Sep 23, 2024

Yes, I cheated and modified the database. The SQL is in the report, i left it there in case another user encounters the same issue and isn't sure what to do.

@c-patrick
Copy link

I encountered the same issue. Recipes were created using a local user, but later switched to oauth for authentication and removed the original user. Restarting the container threw the same error as described.

I fixed it using the same method described by @russell where I just manually changed the IDs for recipes in the database made by the deleted user to a user that exists.

@michael-genson
Copy link
Collaborator

Closing in favor of #3171

@michael-genson michael-genson closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

4 participants