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
5.74k stars 624 forks source link

[nightly] - Meal Plan Notes allow Submission Without Title/Note Text, but Return 422 #2446

Open Grygon opened 1 year ago

Grygon commented 1 year ago

First Check

What is the issue you are experiencing?

image

image

image

Planning to handle in #2399 but submitting since it may be a little while before I get to it.

Deployment

Docker (Linux)

Deployment Details

No response

michael-genson commented 1 year ago

Ah I see, looks like we need to add validation to the frontend. This is the backend:

class CreatePlanEntry(MealieModel):
    date: date
    entry_type: PlanEntryType = PlanEntryType.breakfast
    title: str = ""
    text: str = ""
    recipe_id: UUID | None

    @validator("recipe_id", always=True)
    @classmethod
    def id_or_title(cls, value, values):
        if bool(value) is False and bool(values["title"]) is False:
            raise ValueError(f"`recipe_id={value}` or `title={values['title']}` must be provided")

        return value
Grygon commented 1 year ago

Fixed by 776d56eb75d2738d3a8584b5378c65dd39edd06c

boc-the-git commented 6 months ago

Adding bug confirmed, based on Michael's comment way back when.

dzek69 commented 4 months ago

Bump. Can we get this fix implemented?

It seems that the fix is not a part of this repo, but it's ready to use (idk Vue, but looks correct), so it's probably a quick upgrade that fixes pretty annoying bug 👍🏻

boc-the-git commented 1 month ago

I've just tested the solution posted here and it doesn't seem to work for me - the UI tells me the field is required but doesn't actually stop me submitting it and hitting the 422 error. I'm not going to dig into it any more right now.