duckduckgo / zeroclickinfo-spice

DuckDuckGo Instant Answers based on JavaScript (JSON) APIs
https://duckduckhack.com/
Other
549 stars 942 forks source link

Need help debugging my code #1817

Closed barreyra closed 9 years ago

barreyra commented 9 years ago

Somehow, I can't get my new goodie to work. When I'm doing one query, it works fine. I change the query, and all of a sudden, my goodie stops working and I get the following error:

Error: DDG.exec_template: template is null

I'm not sure what could be causing the problem, and this is my first attempt on working on this environment, so I need help. The query that works returns:

ddg_spice_phish_net([{"showid":"1411064447","showdate":"2015-01-03","showyear":"2015","city":"Miami","state":"FL","country":"USA","venue":"American Airlines Arena","setlistnotes":"This show was webcast via&nbsp;<a href=\"http:\/\/www.livephish.com\/\">LivePhish<\/a>. Mule included&nbsp;a Smoke on the Water tease by Trey. DWD contained an Axilla tease from Trey and was unfinished. Hood included a Happy Birthday tease by Trey and an Auld Lang Syne tease from Mike.&nbsp;The Birds was quoted in Suzy.","venueid":"274","url":"http:\/\/phish.net\/setlists\/?d=2015-01-03","mmddyy":"01\/03\/2015","nicedate":"January 03, 2015","relativetime":"4 months ago","setlistdata":"<p class='pnetset pnetset1'><span class='pnetsetlabel'>Set 1:<\/span> <a href=\"http:\/\/phish.net\/song\/maze\" rev=\"maze\" rel=\"364\">Maze<\/a>,  <a href=\"http:\/\/phish.net\/song\/acdc-bag\" rev=\"acdc-bag\" rel=\"8\">AC\/DC Bag<\/a> >  <a href=\"http:\/\/phish.net\/song\/divided-sky\" rev=\"divided-sky\" rel=\"161\">Divided Sky<\/a>,  <a href=\"http:\/\/phish.net\/song\/cavern\" rev=\"cavern\" rel=\"108\">Cavern<\/a> >  <a href=\"http:\/\/phish.net\/song\/scent-of-a-mule\" rev=\"scent-of-a-mule\" rel=\"490\">Scent of a Mule<\/a>,  <a href=\"http:\/\/phish.net\/song\/plasma\" rev=\"plasma\" rel=\"1085\">Plasma<\/a>,  <a href=\"http:\/\/phish.net\/song\/devotion-to-a-dream\" rev=\"devotion-to-a-dream\" rel=\"2423\">Devotion To a Dream<\/a>,  <a href=\"http:\/\/phish.net\/song\/water-in-the-sky\" rev=\"water-in-the-sky\" rel=\"650\">Water in the Sky<\/a>,  <a href=\"http:\/\/phish.net\/song\/split-open-and-melt\" rev=\"split-open-and-melt\" rel=\"529\">Split Open and Melt<\/a>,  <a href=\"http:\/\/phish.net\/song\/character-zero\" rev=\"character-zero\" rel=\"113\">Character Zero<\/a><\/p><p class='pnetset pnetset2'><span class='pnetsetlabel'>Set 2:<\/span> <a href=\"http:\/\/phish.net\/song\/stealing-time-from-the-faulty-plan\" rev=\"stealing-time-from-the-faulty-plan\" rel=\"539\">Stealing Time From the Faulty Plan<\/a> >  <a href=\"http:\/\/phish.net\/song\/down-with-disease\" rev=\"down-with-disease\" rel=\"174\">Down with Disease<\/a><sup>[1]<\/sup> >  <a href=\"http:\/\/phish.net\/song\/light\" rev=\"light\" rel=\"339\">Light<\/a> ->  <a href=\"http:\/\/phish.net\/song\/sneakin-sally-through-the-alley\" rev=\"sneakin-sally-through-the-alley\" rel=\"518\">Sneakin' Sally Through the Alley<\/a> >  <a href=\"http:\/\/phish.net\/song\/sand\" rev=\"sand\" rel=\"485\">Sand<\/a> >  <a href=\"http:\/\/phish.net\/song\/harry-hood\" rev=\"harry-hood\" rel=\"250\">Harry Hood<\/a> >  <a href=\"http:\/\/phish.net\/song\/suzy-greenberg\" rev=\"suzy-greenberg\" rel=\"545\">Suzy Greenberg<\/a> <p class='pnetset pnetsete'><span class='pnetsetlabel'>Encore:<\/span> <a href=\"http:\/\/phish.net\/song\/good-times-bad-times\" rev=\"good-times-bad-times\" rel=\"235\">Good Times Bad Times<\/a> <p class='pnetfootnotes'>[1] Unfinished.<br \/><\/p>"}])

The query that fails returns:

ddg_spice_phish_net([{"artist":"1","showid":"1253068364","showdate":"1995-12-31","showyear":"1995","meta":"","city":"New York","state":"NY","country":"USA","venue":"Madison Square Garden","setlistnotes":"Reba did not have the whistling ending. The narration in Mockingbird discussed how Phish makes time in the Phish Time Factory, which set up the New Year&rsquo;s Eve stunt. The Phish debut of Shine featured Tom Marshall on vocals. Drowned included a tease of Fire on the Mountain shortly before Lizards. Trey teased Shine in Runaway Jim.&nbsp;Mike&#39;s Song contained a Dave&#39;s Energy Guide tease from Page. The second set ended with a Digital Delay Loop Jam out of Mike&rsquo;s, and the third set opened with the Phish Time Factory machine. All four band members dressed as scientists playing with synths while lights flashed and Van de Graff generators zapped. Fish&nbsp;was lifted up in a bed as Father Time and was reborn as the Baby New Year. Weekapaug featured Auld Lang Syne, Dreaming (Blondie), and Spooky teases and was unfinished. This was the first performance of Sanity since June 24, 1994 (147 shows). This show was officially released as <em>New Year&#39;s Eve 1995 - Live at Madison Square Garden.<\/em>","venuenotes":"","venueid":"157","url":"http:\/\/phish.net\/setlists\/?d=1995-12-31","artist-name":"Phish","mmddyy":"12\/31\/1995","nicedate":"December 31, 1995","relativetime":"19 years ago","setlistdata":"<p class='pnetset pnetset1'><span class='pnetsetlabel'>Set 1:<\/span> <a href=\"http:\/\/phish.net\/song\/punch-you-in-the-eye\" rev=\"punch-you-in-the-eye\" rel=\"447\">Punch You In the Eye<\/a>,  <a href=\"http:\/\/phish.net\/song\/the-sloth\" rev=\"the-sloth\" rel=\"602\">The Sloth<\/a> >  <a href=\"http:\/\/phish.net\/song\/reba\" rev=\"reba\" rel=\"455\">Reba<\/a><sup>[1]<\/sup>,  <a href=\"http:\/\/phish.net\/song\/the-squirming-coil\" rev=\"the-squirming-coil\" rel=\"603\">The Squirming Coil<\/a> >  <a href=\"http:\/\/phish.net\/song\/maze\" rev=\"maze\" rel=\"364\">Maze<\/a>,  <a href=\"http:\/\/phish.net\/song\/colonel-forbins-ascent\" rev=\"colonel-forbins-ascent\" rel=\"126\">Colonel Forbin's Ascent<\/a> >  <a href=\"http:\/\/phish.net\/song\/fly-famous-mockingbird\" rev=\"fly-famous-mockingbird\" rel=\"695\">Fly Famous Mockingbird<\/a><sup>[2]<\/sup> >  <a href=\"http:\/\/phish.net\/song\/shine-2\" rev=\"shine-2\" rel=\"506\">Shine<\/a><sup>[3]<\/sup> >  <a href=\"http:\/\/phish.net\/song\/fly-famous-mockingbird\" rev=\"fly-famous-mockingbird\" rel=\"695\">Fly Famous Mockingbird<\/a> >  <a href=\"http:\/\/phish.net\/song\/sparkle\" rev=\"sparkle\" rel=\"525\">Sparkle<\/a> >  <a href=\"http:\/\/phish.net\/song\/chalk-dust-torture\" rev=\"chalk-dust-torture\" rel=\"110\">Chalk Dust Torture<\/a><\/p><p class='pnetset pnetset2'><span class='pnetsetlabel'>Set 2:<\/span> <a href=\"http:\/\/phish.net\/song\/drowned\" rev=\"drowned\" rel=\"178\">Drowned<\/a> ->  <a href=\"http:\/\/phish.net\/song\/the-lizards\" rev=\"the-lizards\" rel=\"586\">The Lizards<\/a>,  <a href=\"http:\/\/phish.net\/song\/axilla-part-ii\" rev=\"axilla-part-ii\" rel=\"38\">Axilla (Part II)<\/a> >  <a href=\"http:\/\/phish.net\/song\/runaway-jim\" rev=\"runaway-jim\" rel=\"479\">Runaway Jim<\/a>,  <a href=\"http:\/\/phish.net\/song\/strange-design\" rev=\"strange-design\" rel=\"542\">Strange Design<\/a>,  <a href=\"http:\/\/phish.net\/song\/hello-my-baby\" rev=\"hello-my-baby\" rel=\"255\">Hello My Baby<\/a>,  <a href=\"http:\/\/phish.net\/song\/mikes-song\" rev=\"mikes-song\" rel=\"381\">Mike's Song<\/a> ->  <a href=\"http:\/\/phish.net\/song\/digital-delay-loop-jam\" rev=\"digital-delay-loop-jam\" rel=\"157\">Digital Delay Loop Jam<\/a><\/p><p class='pnetset pnetset3'><span class='pnetsetlabel'>Set 3:<\/span> <a href=\"http:\/\/phish.net\/song\/auld-lang-syne\" rev=\"auld-lang-syne\" rel=\"35\">Auld Lang Syne<\/a> >  <a href=\"http:\/\/phish.net\/song\/weekapaug-groove\" rev=\"weekapaug-groove\" rel=\"653\">Weekapaug Groove<\/a><sup>[4]<\/sup> >  <a href=\"http:\/\/phish.net\/song\/sea-and-sand\" rev=\"sea-and-sand\" rel=\"493\">Sea and Sand<\/a>,  <a href=\"http:\/\/phish.net\/song\/you-enjoy-myself\" rev=\"you-enjoy-myself\" rel=\"690\">You Enjoy Myself<\/a>,  <a href=\"http:\/\/phish.net\/song\/sanity\" rev=\"sanity\" rel=\"486\">Sanity<\/a>,  <a href=\"http:\/\/phish.net\/song\/frankenstein\" rev=\"frankenstein\" rel=\"213\">Frankenstein<\/a> <p class='pnetset pnetsete'><span class='pnetsetlabel'>Encore:<\/span> <a href=\"http:\/\/phish.net\/song\/johnny-b-goode\" rev=\"johnny-b-goode\" rel=\"315\">Johnny B. Goode<\/a> <p class='pnetfootnotes'>[1] No whistling.<br \/>[2] Narration discussed how Phish makes time in the Phish Time Factory.<br \/>[3] Phish debut; Tom Marshall on vocals.<br \/>[4] Unfinished.<br \/><\/p>"}])
russellholt commented 9 years ago

is there somewhere we can see the code?

barreyra commented 9 years ago

I just pushed it here. You will not be able to replicate my results as I removed the API key phish.net gave me for this, as I think it's intended to be private. You can go to http://api.phish.net/ and request one.

javathunderman commented 9 years ago

@barreyra You can always ask questions on the IRC or on the Gitter chatroom- you might be able to get help faster that way.

moollaza commented 9 years ago

@barreyra sorry for the delay -- the code looks good at first glance -- I can only imagine the API response is changing and causing problems.

I would suggest you use a built-in template group, other than base which is only meant to be used as a last resort and also please wrap your callback function in a closure as that's our standard format for the JS files.

I don't suspect that'll solve the problem, but I'll be a little happier with the code :)

moollaza commented 9 years ago

@barreyra is this still an issue?