first_word and trunc templates choke on some examples
mx781 opened this issue · 4 comments
// first word
wtf.fetch("Formula One drivers from Finland", "en")
// trunc
wtf.fetch("2007 FIFA Women's World Cup Group A", "en")
@spencermountain reporting here in case you know the solution right away - if not, will dig into these myself soon
Full output:
//first word
TypeError: Cannot read properties of undefined (reading 'split')
at first word (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:4782:18)
at parseTemplate (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8416:34)
at parseNested (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8700:26)
at /foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8697:38
at Array.forEach (<anonymous>)
at parseNested (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8697:22)
at /foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8697:38
at Array.forEach (<anonymous>)
at parseNested (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8697:22)
at /foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8722:30
// trunc
TypeError: Cannot read properties of undefined (reading 'substr')
at Object.trunc (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:4787:22)
at parseTemplate (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8416:34)
at parseNested (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8700:26)
at /foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8697:38
at Array.forEach (<anonymous>)
at parseNested (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8697:22)
at /foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8697:38
at Array.forEach (<anonymous>)
at parseNested (/foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8697:22)
at /foo/node_modules/wtf_wikipedia/builds/wtf_wikipedia.cjs:8722:30
oof, a runtime error - you're on the ball.
yeah! go for it - otherwise I can do it later this evening.
thank you.
For the first one it looks the issue is that the first word
template has a F1Stat
template nested inside it, which is not supported, so presumably it doesn't return anything useful. I guess this could be fixed with a if (str !== undefined)
clause, but I reckon this could happen in many other templates that assume str
is not undefined, so this would be a poor patch and should probably be handled in the "handled unknown template" logic?
two more to add to the pile
// fails on percentage template
wtf.fetch("Sacramento Mountain Lions", "es")
// fails on min template
wtf.fetch("Phase finale du Championnat du monde masculin de handball 2019", "fr")
got em - fixed in 10.1.4
thank you for your help - please share any more that you find. These templates bugs are pretty whackamole.
cheers