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

Panic crash on import JSON or backup generated by Mealie #471

Closed
pihomeserver opened this issue Jan 8, 2025 · 8 comments · Fixed by #473 or #483
Closed

Panic crash on import JSON or backup generated by Mealie #471

pihomeserver opened this issue Jan 8, 2025 · 8 comments · Fixed by #473 or #483
Assignees
Labels
bug Something isn't working
Milestone

Comments

@pihomeserver
Copy link
Contributor

Describe the bug
I try to upload a Mealie JSON file or a full backup (ZIP)

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Add Recipe'
  2. Click on 'Import'
  3. Select a file or zip file
  4. Click import

Expected behavior
There should be no panic and at least an error handling with a message

Screenshots
image

Desktop (please complete the following information):

  • OS: Dabian Bookworm
  • Browser : Brave (Chrome based)
  • Version Brave Version 1.73.104 Chromium: 131.0.6778.204 (Official Build) (64-bit)](https://brave.com/latest/)

Additional context
I'm using the default docker-compose file with nightly build. I've tried with the v1.2.2 release, result is the same

services:
  web:
    image: reaper99/recipya:nightly
    container_name: recipya
    restart: unless-stopped
    environment:
      RECIPYA_EMAIL: ""
      RECIPYA_EMAIL_SENDGRID: ""
      RECIPYA_DI_KEY: ""
      RECIPYA_DI_ENDPOINT: ""
      RECIPYA_SERVER_AUTOLOGIN: false
      RECIPYA_SERVER_IS_DEMO: false
      RECIPYA_SERVER_IS_PROD: false
      RECIPYA_SERVER_NO_SIGNUPS: true
      RECIPYA_SERVER_PORT: 8078
      RECIPYA_SERVER_URL: "http://0.0.0.0"
    ports:
      - 9091:8078
    volumes:
      - ./recipya:/root/.config/Recipya

JSON File is

{
    "id": "134372c8-1b49-41e5-a2d2-3249cc7bdb12",
    "user_id": "499aa092-e3fe-46e7-ac5e-9ddf360c9eee",
    "household_id": "67858612-ba5b-470c-bd0d-20b7fdf9a88a",
    "group_id": "0d7fc2c1-58f4-4c88-8177-083263e467c4",
    "name": "Mini cannelés chorizo comté au thermomix",
    "slug": "mini-canneles-chorizo-comte-au-thermomix",
    "image": "wTJi",
    "recipe_servings": 24.0,
    "recipe_yield_quantity": 0.0,
    "recipe_yield": "",
    "total_time": null,
    "prep_time": "15 minutes",
    "cook_time": null,
    "perform_time": "54 minutes",
    "description": "Qui ne connait pas le cannelé, ce petit gâteau Bordelais irresistible à pâte molle et tendre. Le voici revisité en version salée pour un apéro légèrement relevé, avec du chorizo et du comté.\r\n\nL'essayer c'est l'adopter :)",
    "recipe_category": [],
    "tags": [],
    "tools": [],
    "rating": 4.0,
    "org_url": "https://www.cookomix.com/recettes/mini-canneles-chorizo-comte-thermomix/",
    "date_added": "2024-12-18",
    "date_updated": "2024-12-31T10:20:45.610286Z",
    "created_at": "2024-12-18T08:18:02.011499Z",
    "updated_at": "2024-12-31T10:20:45.622388Z",
    "last_made": null,
    "recipe_ingredient": [
        {
            "quantity": 1.0,
            "unit": null,
            "food": null,
            "note": "Beurre - 30 grammes",
            "is_food": false,
            "disable_amount": true,
            "display": "Beurre - 30 grammes",
            "title": null,
            "original_text": null,
            "reference_id": "1c728d6b-fd56-4516-a83a-1e742163d879"
        },
        {
            "quantity": 1.0,
            "unit": null,
            "food": null,
            "note": "Lait demi-écrémé - 250 ml",
            "is_food": false,
            "disable_amount": true,
            "display": "Lait demi-écrémé - 250 ml",
            "title": null,
            "original_text": null,
            "reference_id": "e5ea6b2d-9fb3-4c21-97c8-76c0f46ce407"
        },
        {
            "quantity": 1.0,
            "unit": null,
            "food": null,
            "note": "Chorizo - 50 grammes",
            "is_food": false,
            "disable_amount": true,
            "display": "Chorizo - 50 grammes",
            "title": null,
            "original_text": null,
            "reference_id": "04ae6888-705b-4cb7-be99-bf747248422c"
        },
        {
            "quantity": 1.0,
            "unit": null,
            "food": null,
            "note": "Comté - 60 grammes",
            "is_food": false,
            "disable_amount": true,
            "display": "Comté - 60 grammes",
            "title": null,
            "original_text": null,
            "reference_id": "2ebad54d-ab1a-41e6-87af-84196fc7cbec"
        },
        {
            "quantity": 1.0,
            "unit": null,
            "food": null,
            "note": "Oeuf - 2",
            "is_food": false,
            "disable_amount": true,
            "display": "Oeuf - 2",
            "title": null,
            "original_text": null,
            "reference_id": "a621f5f7-5b78-4a63-9564-cc4df260d0f2"
        },
        {
            "quantity": 1.0,
            "unit": null,
            "food": null,
            "note": "Farine - 60 grammes",
            "is_food": false,
            "disable_amount": true,
            "display": "Farine - 60 grammes",
            "title": null,
            "original_text": null,
            "reference_id": "cd53e2eb-8163-4c84-a593-8fcc025a1431"
        },
        {
            "quantity": 1.0,
            "unit": null,
            "food": null,
            "note": "Sel - 1 pincée",
            "is_food": false,
            "disable_amount": true,
            "display": "Sel - 1 pincée",
            "title": null,
            "original_text": null,
            "reference_id": "2928a65b-12be-4ee1-9c6a-32de40c2917e"
        },
        {
            "quantity": 1.0,
            "unit": null,
            "food": null,
            "note": "Poivre - 1 pincée",
            "is_food": false,
            "disable_amount": true,
            "display": "Poivre - 1 pincée",
            "title": null,
            "original_text": null,
            "reference_id": "e42c649c-12ad-44e2-a4b8-87387442f2ff"
        }
    ],
    "recipe_instructions": [
        {
            "id": "02e8a3ea-1696-4adc-8282-a96be0df0aec",
            "title": "",
            "summary": "",
            "text": "Préchauffer le four à 180°C.",
            "ingredient_references": []
        },
        {
            "id": "6a841504-b4ad-408a-9281-0acb48c1573e",
            "title": "",
            "summary": "",
            "text": "Dans une casserolle mettre 30 grammes de beurre coupés en morceaux",
            "ingredient_references": []
        },
        {
            "id": "a67f84b0-3960-4776-b01f-fba47aa20738",
            "title": "",
            "summary": "",
            "text": "Ajouter le lait",
            "ingredient_references": []
        },
        {
            "id": "a4f49ac8-1280-4c6b-8146-2b62d5b3a706",
            "title": "",
            "summary": "",
            "text": "Faire chauffer à feu moyen en tournant régulièrement",
            "ingredient_references": []
        },
        {
            "id": "92adc312-0070-4f74-8e1f-6684c352fbfe",
            "title": "",
            "summary": "",
            "text": "Dans un saladier, ajouter 1 oeuf et le jaune d'oeuf",
            "ingredient_references": []
        },
        {
            "id": "2aa1d7c3-31aa-41f2-a628-c518b72f604e",
            "title": "",
            "summary": "",
            "text": "Ajouter 60 grammes de farine",
            "ingredient_references": []
        },
        {
            "id": "f77dba58-d336-470e-8232-cbe5cca1a6bc",
            "title": "",
            "summary": "",
            "text": "Ajouter 1 pincée de sel (à ajuster en fonction des goûts)",
            "ingredient_references": []
        },
        {
            "id": "b4fff326-6e32-4edf-8515-34af3f6b17c6",
            "title": "",
            "summary": "",
            "text": "Ajouter 1 pincée de poivre (à ajuster en fonction des goûts) ",
            "ingredient_references": []
        },
        {
            "id": "cb4ac495-af3d-4bca-8452-af6631ac31e9",
            "title": "",
            "summary": "",
            "text": "Mélanger pour obtenir une pâte lisse",
            "ingredient_references": []
        },
        {
            "id": "88e3cc68-74f5-4800-9b57-e6530cfda543",
            "title": "",
            "summary": "",
            "text": "Ajouter progressivement le mélange lait/beurre",
            "ingredient_references": []
        },
        {
            "id": "9a6c5dae-d4cf-4edd-aadf-c776b5db415a",
            "title": "",
            "summary": "",
            "text": "Ajouter le comté et le chorizo coupés en dés. Bien mélanger",
            "ingredient_references": []
        },
        {
            "id": "e63371c4-cbfb-4108-a4c3-bd7ec07eebd4",
            "title": "",
            "summary": "",
            "text": "Transvaser dans des moules à mini-cannelés en remplissant aux 3/4.\nLa quantité doit permettre de faire 2 fournées de 12.",
            "ingredient_references": []
        },
        {
            "id": "d97c56d4-a7a6-4237-9c15-ccf64f715903",
            "title": "",
            "summary": "",
            "text": "Mettre dans le four pendant 25 min à 180°C. Mode chaleur tournante. Adaptez la cuisson en fonction de vos moules et/ou de votre four.",
            "ingredient_references": []
        }
    ],
    "nutrition": {
        "calories": "37",
        "carbohydrate_content": null,
        "cholesterol_content": null,
        "fat_content": null,
        "fiber_content": null,
        "protein_content": null,
        "saturated_fat_content": null,
        "sodium_content": null,
        "sugar_content": null,
        "trans_fat_content": null,
        "unsaturated_fat_content": null
    },
    "settings": {
        "public": true,
        "show_nutrition": false,
        "show_assets": false,
        "landscape_view": false,
        "disable_comments": false,
        "disable_amount": true,
        "locked": false
    },
    "assets": [],
    "notes": [],
    "extras": {},
    "comments": []
}
@pihomeserver pihomeserver added the bug Something isn't working label Jan 8, 2025
@pihomeserver pihomeserver changed the title Panic crash on import JSON from Mealie Panic crash on import JSON or backup generated by Mealie Jan 8, 2025
@reaper47 reaper47 self-assigned this Jan 8, 2025
@reaper47 reaper47 added this to Recipya Jan 8, 2025
@reaper47 reaper47 moved this to In Progress in Recipya Jan 8, 2025
@reaper47
Copy link
Owner

reaper47 commented Jan 9, 2025

It seems Mealie updated the fields of its API spec from camel case to snake case. For example, userId and prepTime are now user_id and prep_time. I'll fix it.

@reaper47 reaper47 linked a pull request Jan 10, 2025 that will close this issue
@reaper47 reaper47 added this to the v1.2.3 milestone Jan 13, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Recipya Jan 13, 2025
@reaper47
Copy link
Owner

You should now be able to import JSON recipes from Mealie and import all of them from the settings.

@pihomeserver
Copy link
Contributor Author

pihomeserver commented Jan 14, 2025

I confirm that import works. Few fields are missing like prep time, cook time and total time. I will try to have a look why (i have never used Go before)
A full Mealie backup can't be imported but i don't know if the feature exists

@reaper47
Copy link
Owner

reaper47 commented Jan 14, 2025

Perfect! Could you please send me JSON recipes where the import didn't fully work? Or if you want to have a look, the logic is found here: https://github.com/reaper47/recipya/blob/main/internal/integrations/mealie.go

I had a look at importing a Mealie backup zip, but it's too difficult to implement because the data lies in a sqlite3 database. However, it might actually be possible to connect to the database and fetch the information from it. That should be a fun challenge!

Meanwhile, you can import all your Mealie recipes at once from the settings. You provide the base URL and password of your Mealie instance and Recipya will then call the Mealie API to import all recipes, including images.

Import other data such as cooking books and shopping lists is something that would be sweet to implement eventually.

@pihomeserver
Copy link
Contributor Author

pihomeserver commented Jan 14, 2025

In my case the database access will be complex due to a reverse proxy in front of my instance. It's easier to use your solution to provide URL and credentials. I will try that today
update Import from Mealie docker instance fails. I have to see how to get logs to debug and understand what the issue is

About the JSON it's the one in this issue. prep_time and cook_time are not used and set to 0 after import

@reaper47
Copy link
Owner

The times have been fixed. It will be available in the next nightly build. I wonder why importing Mealie from Docker isn't working.

@pihomeserver
Copy link
Contributor Author

pihomeserver commented Jan 16, 2025

Import works thank you

It's my configuration i guess. I have reverse proxy combine to different networks so requests are lost somewhere

@pihomeserver
Copy link
Contributor Author

Confirmation that once my both containers Mealie and Recipya are in the same docker-compose and network they can access each other and then import Mealie's recipies perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
2 participants