mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
7.35k stars 734 forks source link

[BUG] - Removing a recipe ingredient doesn't remove its links to steps #3956

Open YodaDaCoda opened 3 months ago

YodaDaCoda commented 3 months ago

First Check

What is the issue you are experiencing?

When a recipe ingredient is removed from the recipe, any recipe-step links for that ingredient are not removed from the steps.

Steps to Reproduce

  1. Create a new recipe or edit an existing one
  2. Link an ingredient to a step
  3. Remove the ingredient from the recipe
  4. Open the ingredient's JSON and observe that there exists an ingredientReferences on the step without a corresponding recipeIngredient.

Please provide relevant logs

N/A

Mealie Version

v1.10.2

Deployment

Docker (Linux)

Additional Deployment Details

No response

YodaDaCoda commented 3 months ago

I discovered this when the Mealient app for Android wouldn't display one of my recipes after editing it. While I do think Mealient should handle this situation more gracefully, Mealie should avoid this in the first place.

kirmanak/Mealient#284

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

YodaDaCoda commented 2 months ago

Can this be re-opened?

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

YodaDaCoda commented 1 month ago

I tried to figure out how to do this some weeks ago but couldn't see a clear path where I might make changes. Happy to try again with some direction?

michael-genson commented 1 month ago

You'll probably want to add a check in the recipe service upon updating to remove any ingredient links for non-existent ingredients:

https://github.com/mealie-recipes/mealie/blob/mealie-next/mealie/services/recipe/recipe_service.py