merefield encountered a onebox failure when trying to preview a link from NBC San Diego. The error message indicated an unexpected character in the JSON response. Despite the link previewing fine in iframely and Facebook, the onebox failed.
joffreyjaffeux suspected that the issue was due to the server expecting JSON but receiving HTML instead. After investigating, joffreyjaffeux found that the NBC San Diego server was returning a 404 error with HTML content, but with a 200 HTTP status code, which caused the JSON parser to fail.
The issue is likely due to a bug on NBC San Diego’s side, as the URL for the oembed content comes from their page source. joffreyjaffeux and zogstrip agreed that it’s not worth investing time to fix this issue, as it’s not a problem with the onebox code. merefield also tried to report the issue to NBC San Diego through their website feedback form, but was unable to submit the report due to a faulty Captcha system.
Failed to onebox https://www.nbcsandiego.com/news/national-international/CVS-to-Sell-CBD-Products-in-800-Stores-in-8-States-507484191.html unexpected character () at line 9, column 2 [parse.c:704]
2019-03-22 10:42:42 - MultiJson::ParseError - 767: unexpected token at '<head>
<title>404 Not Found</title>
</head><body>
<h1>404 Not Found</h1>
<p>The provided content is neither a Video Release nor does it contain a Video Release in Related Media.<br>Example Request Format: https://www.nbcnewyork.com/services/oembed/?url=https://www.nbcnewyork.com/sample/path/Sample-Article-Example-12345678.html</p>
</body></html>
':
/Users/joffreyjaffeux/.rubies/ruby-2.6.1/lib/ruby/2.6.0/json/common.rb:156:in `parse'
/Users/joffreyjaffeux/.rubies/ruby-2.6.1/lib/ruby/2.6.0/json/common.rb:156:in `parse'
/Users/joffreyjaffeux/.gem/ruby/2.6.1/gems/multi_json-1.13.1/lib/multi_json/adapters/json_common.rb:14:in `load'
/Users/joffreyjaffeux/.gem/ruby/2.6.1/gems/multi_json-1.13.1/lib/multi_json/adapter.rb:21:in `load'
/Users/joffreyjaffeux/.gem/ruby/2.6.1/gems/multi_json-1.13.1/lib/multi_json.rb:122:in `load'
/Users/joffreyjaffeux/Projects/onebox/lib/onebox/oembed.rb:6:in `initialize'
The thing is, this URL comes from their page source:
<link rel="alternate" type="application/json+oembed"
href="https://www.nbcnewyork.com/services/oembed/?url=https://www.nbcsandiego.com/news/national-international/CVS-to-Sell-CBD-Products-in-800-Stores-in-8-States-507484191.html"
title="CVS to Sell CBD Products in 800 Stores in 8 States - NBC 7 San Diego " />
Forgive me if I sound stupid here: there’s no way we could make this more resilient and tolerate this as basic goal is to retrieve just title, excerpt, thumbnail, etc.?