Skip to content

MealplanResponse parsing fails when recipe dateAdded is null #728

@TheZargs

Description

@TheZargs

Bug Description

The Home Assistant Mealie integration crashes with an InvalidFieldValue exception
when fetching mealplans that contain recipes where dateAdded is null. This
completely breaks the integration's mealplan coordinator — no mealplan data is
returned at all.

Traceback

mashumaro.exceptions.InvalidFieldValue: Field "date_added" of type date in
BaseRecipe has invalid value None
mashumaro.exceptions.InvalidFieldValue: Field "recipe" of type Optional[BaseRecipe]
in Mealplan has invalid value {...}
mashumaro.exceptions.InvalidFieldValue: Field "items" of type list[Mealplan] in
MealplanResponse has invalid value [...]

Root Cause

BaseRecipe declares date_added as date, but the Mealie API legitimately
returns null for this field — for example on recipes imported via third-party
sync tools (e.g. kptncook). Since one affected recipe poisons the entire
MealplanResponse, the whole mealplan fetch fails.

Expected Behavior

date_added should be typed as Optional[date] so that null values are
handled gracefully instead of crashing the entire response deserialization.

Suggested Fix

# Before
date_added: date

# After
date_added: Optional[date] = None

Environment

  • Home Assistant (current stable)
  • Mealie (self-hosted, current stable)
  • Recipes with dateAdded: null imported via kptncook sync

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions