Skip to content

[BUG] - Unable to save recipes with sub-recipes as ingredients in multi-group setup #6652

@ImanuelBertrand

Description

@ImanuelBertrand

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?

When saving a recipe with another recipe as an ingredient, and that sub-recipe (technically: its slug) exists more than once in the DB, Mealie will show "Unknown error".
My instance has two groups to separate data, but many of the recipes are "shared" (technically not shared but re-imported), so many of the slugs appear twice in the DB.

Steps to Reproduce

I have set up a test case in the demo instance. I don't know how long the data is persisted there, though.

  1. Login with the default user
  2. Open Ciasto Bonifacy
  3. Add recipe Bulgogi - Koreansk favorit as an ingredient
    I created a dummy recipe with the same name in the group stumpf for this testcase
  4. Save Ciasto Bonifacy
  5. Error

Please provide relevant logs

[ERROR|recipe_crud_routes|L111] 2025-12-03T16:56:25: Multiple rows were found when one or none was required
Traceback (most recent call last):
  File "/opt/mealie/lib/python3.12/site-packages/mealie/routes/recipe/recipe_crud_routes.py", line 384, in update_one
	recipe = self.service.update_one(slug, data)
			 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mealie/lib/python3.12/site-packages/mealie/services/recipe/recipe_service.py", line 441, in update_one
	new_data = self.group_recipes.update(recipe.slug, update_data)
			   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mealie/lib/python3.12/site-packages/mealie/repos/repository_generic.py", line 214, in update
	entry.update(session=self.session, **new_data)
  File "/opt/mealie/lib/python3.12/site-packages/mealie/db/models/_model_base.py", line 32, in update
	self.__init__(*args, **kwargs)
  File "<string>", line 6, in __init__
  File "/opt/mealie/lib/python3.12/site-packages/mealie/db/models/recipe/api_extras.py", line 19, in wrapper
	return func(*args, extras=extras, **kwargs)
		   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mealie/lib/python3.12/site-packages/mealie/db/models/_model_utils/auto_init.py", line 190, in wrapper
	return init(self, *args, **kwargs)
		   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mealie/lib/python3.12/site-packages/mealie/db/models/recipe/recipe.py", line 211, in __init__
	self.recipe_ingredient = [RecipeIngredientModel(**ingr, session=session) for ingr in recipe_ingredient]
							  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 4, in __init__
  File "/opt/mealie/lib/python3.12/site-packages/sqlalchemy/orm/state.py", line 571, in _initialize_instance
	with util.safe_reraise():
		 ^^^^^^^^^^^^^^^^^^^
  File "/opt/mealie/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 224, in __exit__
	raise exc_value.with_traceback(exc_tb)
  File "/opt/mealie/lib/python3.12/site-packages/sqlalchemy/orm/state.py", line 569, in _initialize_instance
	manager.original_init(*mixed[1:], **kwargs)
  File "/opt/mealie/lib/python3.12/site-packages/mealie/db/models/_model_utils/auto_init.py", line 179, in wrapper
	instance = session.execute(stmt).scalars().one_or_none()
			   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mealie/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1803, in one_or_none
	return self._only_one_row(
		   ^^^^^^^^^^^^^^^^^^^
  File "/opt/mealie/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 813, in _only_one_row
	raise exc.MultipleResultsFound(
sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required
[INFO|httptools_impl|L476] 2025-12-03T16:56:25: 2001:a61:c6d:f601:28b8:7130:4cc0:2cb5:0 - "PUT /api/recipes/lauchquiche HTTP/1.1" 500

Mealie Version

First noticed in 3.5.0, still happens in 3.6.1 / build 28d00f7dd5397b7b79646dee0cefcd5af068d542

Deployment

Docker (Linux)

Additional Deployment Details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions