Closed
Description
Hello please can you'll me what im doing wrong ? i have spent hours trying to tag a recipe via API but cant get the format - keep getting internal server error. i have cheked the id numbers for the tag and the recipe
this is the code im using , got same in the API too
curl -X 'POST'
'http://192.168.1.242:9926/api/recipes/bulk-actions/tag'
-H 'accept: application/json'
-H 'Authorization: Bearer MY SECRET TOKEN'
-H 'Content-Type: application/json'
-d '{
"recipes": [
"a44da20a-2fa0-44aa-ab4e-7c355e05b70e"
],
"tags": [
{
"name": "Image-Req",
"id": "e1c668af-01db-4f47-ad14-7a663d3722ed",
"slug": "image-req"
}
]
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
robertdanahome commentedon Apr 13, 2025
I have hit the same error updating when attempting to add tags to a single recipe (not bulk), and with some AI help I think I found the issue.
Description:
When attempting to update a recipe's tags using the API endpoint PATCH /api/recipes/{recipe_slug}, the request fails with a 500 Internal Server Error. The backend logs show a TypeError: init() missing 1 required positional argument: 'group_id'.
This issue seems to stem from an inconsistency between the Pydantic schema used for API validation and the underlying database model for Tags.
Steps to Reproduce:
Identify an existing recipe slug (YOUR_RECIPE_SLUG), an existing tag name/slug (Existing Tag Name/existing-tag-slug), your Mealie URL (YOUR_MEALIE_URL), your API key (YOUR_MEALIE_API_KEY), and the Group ID the recipe belongs to (YOUR_VALID_GROUP_ID).
Execute the following curl command:
Expected Behavior:
The recipe's tags should be updated successfully with a 200 OK response.
Actual Behavior:
The API returns a 500 Internal Server Error. The Mealie backend logs show the following traceback:
Root Cause Analysis:
Similarly, the TagBase schema (mealie/schema/recipe/recipe_category.py), used by the bulk tag action endpoint (/api/recipes/bulk-actions/tag), also lacks group_id.
Because group_id is not defined in the API validation schemas, Pydantic strips this field from the incoming request data before it reaches the database layer.
When the backend attempts to initialize the Tag database model using this processed data, the required group_id argument is missing, causing the TypeError.
Suggested Fix:
Modify the relevant Pydantic schemas to include the group_id field, making it optional to avoid breaking other potential uses:
In mealie/schema/recipe/recipe.py:
In mealie/schema/recipe/recipe_category.py (affecting TagBase via inheritance):
This change allows the group_id to pass through API validation and be available when the Tag database model is initialized.
Submitted as pull request #5342
robertdanahome commentedon Apr 18, 2025
OP, the maintainers just merged the fix I made. This should be in the next release, or if you could patch in the pull request I made. I haven't tried it with batch updates (which this should have fixed), but am able to update tags on individual recipes.