Skip to content

Empty unit name when importing #2690

@Battleman

Description

@Battleman

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions