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

Empty unit name when importing #2690

Closed
Battleman opened this issue Oct 21, 2023 · 5 comments
Closed

Empty unit name when importing #2690

Battleman opened this issue Oct 21, 2023 · 5 comments

Comments

@Battleman
Copy link

Tandoor Version

1.5.6

Setup

Docker / Docker-Compose

Reverse Proxy

Traefik

Other

No response

Bug description

When importing a recipe from a website, and moving fields around, sometimes a non-existing unit is replaced by an empty unit.

Extract from the JSON generated
        {
            "instruction": "Couper l'avocat et le piment en deux, les nettoyer et les émincer. Hacher finement l'oignon rouge.  ",
            "ingredients": [
                {
                    "amount": 0,
                    "food": {
                        "name": "avokado"
                    },
                    "unit": null,
                    "note": "",
                    "original_text": "avokado"
                },
                {
                    "amount": 0,
                    "food": {
                        "name": "grønn chili"
                    },
                    "unit": {
                        "name": ""
                    },
                    "note": "",
                    "original_text": "grønn chili"
                },
                {
                    "amount": 0,
                    "food": {
                        "name": "rødløk"
                    },
                    "unit": {
                        "name": ""
                    },
                    "note": "",
                    "original_text": "rødløk"
                }
            ],
            "show_ingredients_table": true
        },

This particular extract comes from this website, but simply importing the link works immediately. I believe the problem happens when moving ingredients around, before importing.

The API response is a simple 400, indicating that "This field may not be blank" (at the correct place). I've tried entering the ingredient and modifying it, but it doesn't seem possible to simply "delete". I haven't tried manually setting a random unit.

Unfortunately, it's not super easy to reproduce, with clear steps. Happens "sometimes".
Current workaround is to use the browser's console network tab, figure out which ingredient is broken, and delete it altogether from the import. Maybe also simply set a random unit, and delete it afterwards.

Possible solutions:

  • When the unit just contains an empty name, consider it a null unit
  • Prevent the empty unit from appearing in the first place.

Relevant logs

No response

@TandoorRecipes TandoorRecipes deleted a comment from Yubraj977 Oct 27, 2023
@vabene1111
Copy link
Collaborator

that is very strange, fields should not suddenly become empty.

What do you mean by moving fields around, do you mean reordering ingredients or moving them between steps?

@silamon
Copy link

silamon commented Nov 27, 2023

I think it is as simple as,

  • Import the recipe from provided website
  • Open the modal to edit an ingredient without unit (like pepper or salt)
  • Close it without modification
  • Try to import

@vabene1111
Copy link
Collaborator

vabene1111 commented Nov 27, 2023

ok thanks, I will take a look at that, that could be the explanaition

@vabene1111
Copy link
Collaborator

ok so this is actually kind of the expected/intended behavior, the system just does not expect you to open the editor and not enter anything

prepareIngredientEditModal: function (step, ingredient) {
            if (ingredient.unit === null) {
                ingredient.unit = {
                    "name": ""
                }
            }
            if (ingredient.food === null) {
                ingredient.food = {
                    "name": ""
                }
            }
            this.current_edit_ingredient = ingredient
            this.current_edit_step = step
        },

but that of course makes sense, you should be able to just leave the unit empty, i fill fix it

@vabene1111
Copy link
Collaborator

ok so there was actually already a method handling this case but it only triggered when using one of the buttons not the close or clicking in the background. Its now fixed

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

No branches or pull requests

3 participants