Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pydantic Validation For Empty ID String #3160

Conversation

michael-genson
Copy link
Collaborator

@michael-genson michael-genson commented Feb 12, 2024

What type of PR is this?

(REQUIRED)

  • bug

What this PR does / why we need it:

(REQUIRED)

#3157 introduced a placeholder id field to fix an issue where Pydantic chose the wrong model in a type union. However, if it receives an empty string, instead of coercing that to None, it tries to coerce it to a UUID (which fails). This PR adds an explicit validator.

This issue presents itself when parsing a recipe, if you try to click the button to create a missing food/unit based on the parse result. I can't seem to find anywhere else where that happens (the data management page, for example, doesn't do that).

Which issue(s) this PR fixes:

(REQUIRED)

Raised in Discord

Special notes for your reviewer:

(fill-in or delete this section)

I tried to poke around and see where else this might be an issue, but I couldn't find any other id: UUID4 | None situations that don't work as expected ¯\_(ツ)_/¯

Testing

(fill-in or delete this section)

Manually

Copy link
Collaborator

@boc-the-git boc-the-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@boc-the-git boc-the-git merged commit ae03e61 into mealie-recipes:mealie-next Feb 12, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants