Skip to content

Include offending ingredient text in the too-long parse error - #4832

Open
Themazecrawler wants to merge 1 commit into
TandoorRecipes:developfrom
Themazecrawler:fix/ingredient-parser-too-long-hint
Open

Themazecrawler wants to merge 1 commit into
TandoorRecipes:developfrom
Themazecrawler:fix/ingredient-parser-too-long-hint

Conversation

@Themazecrawler

@Themazecrawler Themazecrawler commented Sep 23, 2026 •

Copy link
Copy Markdown

Summary

The ingredient parser rejects anything over 512 characters, but the error it raises doesn't say ingredient triggered it. That's confusing during an import where none of the source ingredients actually look that long (see #4790, someone hitting this on a Mealie import with no obviously long ingredients).

I traced where the message actually ends up: in cookbook/integration/mealie1.py the call to ingredient_parser.parse() isn't wrapped in a try/except, so the ValueError bubbles up to integration.py, which does str(e) straight into the import log the user sees. So whatever we put in the message is what they get.

Now the message includes the first 100 characters of the string that was too long, so at least a truncated version of the offending ingredient shows up in the log instead of a bare "too long" with no context.

Fixes #4790

Test plan

  • Added a test asserting the truncated ingredient text appears in the raised error's message
  • pytest cookbook/tests/other/test_ingredient_parser.py passes (3 passed)

Previously the error just said an ingredient exceeded 512 characters
with no indication which one, making it hard to track down during a
recipe import when none of the source ingredients look that long
(e.g. when strings get concatenated somewhere upstream). Now the
message includes the first 100 characters of the offending string,
which reaches the user directly since integration.py surfaces str(e)
in the import log.

Fixes TandoorRecipes#4790

This branch has not been deployed

No deployments
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.

importer should give a hint when erroring out

1 participant