Skip to content

America's Test Kitchen, failes to parse json due to "tool" list #2523

@sudobash1

Description

@sudobash1

Failing website: www.americastestkitchen.com

Example of failing recipe: https://www.americastestkitchen.com/recipes/8352-vietnamese-style-caramel-chicken-with-broccoli Other recipes I tried on the site also fail.

Checking if valid metadata are present: Yes, I found the recipe json, and was able to import it manually (with slight edits)

Cookbook version: 0.11.2

Problem description (if applicable):

The recipe import fails. Checking the log I see some warnings and these errors:

Error: Undefined array key "id" at /var/www/html/custom_apps/cookbook/lib/Helper/Filter/JSON/RecipeIdTypeFilter.php#13 
Error: Exception trim(): Argument #1 ($string) must be of type string, array given in file '/var/www/html/custom_apps/cookbook/lib/Helper/Filter/JSON/FixToolsFilter.php' line 59

I viewed the page source, and found the json. I manually copied it to a recipe.json file. However I still got an error when trying to view it. It was the same trim error.

I figured that it must be some array that this recipe json has that most others don't. Looking through it, I found this block:

"tool": [
    {
      "@type": "HowToTool",
      "name": "The Best Chef’s Knives for $75 or Less",
      "image": "https://res.cloudinary.com/hksqkdlah/image/upload/ar_1:1,c_fill,dpr_2.0,f_auto,fl_lossy.progressive.strip_profile,g_faces:auto,q_auto:low,w_150/v1/ATK%20Reviews/2021/Inexpensive%20Chefs%20Knives/SIL_Victorinox-Swiss-Army_Fibrox-Pro-8-Chefs-Knife_9754"
    },
    {
      "@type": "HowToTool",
      "name": "Dutch Ovens",
      "image": "https://res.cloudinary.com/hksqkdlah/image/upload/ar_1:1,c_fill,dpr_2.0,f_auto,fl_lossy.progressive.strip_profile,g_faces:auto,q_auto:low,w_150/32547_can-inexpensive-dutch-ovens-2756-square"
    },
    {
      "@type": "HowToTool",
      "name": "Measuring Spoons",
      "image": "https://res.cloudinary.com/hksqkdlah/image/upload/ar_1:1,c_fill,dpr_2.0,f_auto,fl_lossy.progressive.strip_profile,g_faces:auto,q_auto:low,w_150/22995_sil-measuringspoons-cuisipro-747002"
    }
  ],

It contains nothing of value, and after removing it, I was able to load the recipe just fine.

The recipe instructions could use a little cleaning up too. Step 1 is just ## Recipe Instructions which isn't needed. And the last step is ## Test Kitchen Techniques with nothing following--also unneeded.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions