PATCH /api/recipes/{slug} returns 400 "Recipe already exists" whenever tags or recipeCategory is non-empty
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?
Description
Patching a recipe's tags or recipeCategory field to a non-empty value fails with
HTTP 400 "Recipe already exists". This happens even on a recipe that was just created
and has no tags/categories yet, so it isn't a real name/slug collision.
Steps to reproduce
- Create a recipe:
POST /api/recipeswith{"name": "Test Recipe"}-> 201, returns slug - Patch it with no tags:
PATCH /api/recipes/{slug}with a normal body (description, ingredients, instructions, tags: [], recipeCategory: []) -> 200, works fine - Patch it again, this time with
"tags": ["Vegetarian"](or"recipeCategory": ["Dinner"]) in an otherwise identical or even minimal body -> 400:{"detail": {"message": "Recipe already exists", "error": true, "exception": null}}
Also tried
- Plain strings:
"tags": ["Vegetarian"]-> fails - Full objects with an explicit slug:
"tags": [{"name": "Vegetarian", "slug": "vegetarian"}]-> fails identically - A completely separate, minimal PATCH containing only
{"tags": ["Vegetarian"]}-> fails identically - Same result for
recipeCategory, tested independently oftags
So it isn't a request-shape issue, and it isn't specific to combining tags with other fields, the "Recipe already exists" message appears to come from validation logic that seems to be reusing a recipe-slug uniqueness check for tag/category creation.
Expected
The tag/category should be created (this household had never used "Vegetarian" or "Dinner" before) and the patch should succeed, same as any other new tag/category.
Environment
- Mealie version: <fill in, Settings > About>
- Self-hosted
- Recipe created via the API directly (not the UI), for context, though the failure
reproduces with
curl/direct API calls, unrelated to any client
Steps to Reproduce
Steps to reproduce
- Create a recipe:
POST /api/recipeswith{"name": "Test Recipe"}-> 201, returns slug - Patch it with no tags:
PATCH /api/recipes/{slug}with a normal body (description, ingredients, instructions, tags: [], recipeCategory: []) -> 200, works fine - Patch it again, this time with
"tags": ["Vegetarian"](or"recipeCategory": ["Dinner"]) in an otherwise identical or even minimal body -> 400:{"detail": {"message": "Recipe already exists", "error": true, "exception": null}}
Please provide relevant logs
Logs
1. Baseline: patch with empty tags/categories succeeds
PATCH /api/recipes/zzz-delete-full-no-tags Body: {"description": "", "recipeYield": "", "recipeServings": 0, "prepTime": "", "cookTime": "", "totalTime": "", "orgURL": "", "tags": [], "recipeCategory": [], "notes": [], "recipeIngredient": [...], "recipeInstructions": [...]}
-> 200 OK, full recipe object returned, tags: [], recipeCategory: []
2. Same request, tags set to a single new string -> fails
PATCH /api/recipes/zzz-delete-full-with-tags Body: {..., "tags": ["Vegetarian"], "recipeCategory": [], ...} (otherwise identical to #1)
-> 400 Bad Request {"detail": {"message": "Recipe already exists", "error": true, "exception": null}}
3. Same, recipeCategory set instead of tags -> fails identically
PATCH /api/recipes/zzz-delete-full-with-cat Body: {..., "tags": [], "recipeCategory": ["Dinner"], ...}
-> 400 Bad Request {"detail": {"message": "Recipe already exists", "error": true, "exception": null}}
4. Ruling out plain-string format: full {id,name,slug}-style object, still fails
PATCH /api/recipes/zzz-delete-obj-slug-tag Body: {..., "tags": [{"name": "Vegetarian", "slug": "vegetarian"}], ...}
-> 400 Bad Request {"detail": {"message": "Recipe already exists", "error": true, "exception": null}}
(object form without a slug returns a different, expected error first: 422 {"detail": [{"type": "missing", "loc": ["body", "tags", 0, "slug"], "msg": "Field required", "input": {"name": "Vegetarian"}}]} supplying the slug explicitly then reproduces the same 400 as the plain-string case)
5. Ruling out interaction with other fields: minimal second PATCH, tags only
PATCH /api/recipes/zzz-delete-two-step Body: {"tags": ["Vegetarian"]} (recipe already has ingredients/instructions from a prior successful patch, exactly like #1)
-> 400 Bad Request {"detail": {"message": "Recipe already exists", "error": true, "exception": null}}
Environment
Mealie version: v3.28.0 (confirmed via GET /api/app/about) Deployment: Home Assistant Community App wrapper (hassio-addons/app-mealie), self-hosted
Mealie Version
v3.28.0
Deployment
Docker (Linux)
Additional Deployment Details
No response
Source: mealie-recipes/mealie