nextcloud / nextcloud/cookbook
America's Test Kitchen, failes to parse json due to "tool" list
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 641
- Forks
- 113
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 26
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/Helper/Filter/JSON/RecipeIdTypeFilter.php and lib/Helper/Filter/JSON/FixToolsFilter.php, then reproduce the failure with the linked America's Test Kitchen recipe or its copied JSON. Check how the tool list and instruction headings are handled; done means the recipe imports without the reported errors and the unnecessary instruction headings are removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100