zotero / translators

Zotero Translators
http://www.zotero.org/support/dev/translators
1.3k stars 762 forks source link

Wikidata translator fails on items that link to resources with no rdf metadata #3108

Open mvolz opened 1 year ago

mvolz commented 1 year ago

Input:

https://www.wikidata.org/wiki/Q30834230

Output:

>
> (1)(+0000000): Error: cleanAuthor: author must be a string
> 
>     Error: cleanAuthor: author must be a string
>         at Zotero.Utilities.Translate.cleanAuthor (/home/marielle/code/mediawiki/srv/zotero/modules/utilities/utilities.js:173:10)
>         at Function.cleanAuthor (/home/marielle/code/mediawiki/srv/zotero/src/translation/sandboxManager.js:96:17)
>         at eval (eval at <anonymous> (/home/marielle/code/mediawiki/srv/zotero/src/translation/sandboxManager.js:70:4), <anonymous>:259:26)
>         at /home/marielle/code/mediawiki/srv/zotero/modules/translate/src/utilities_translate.js:414:5
>         at processTicksAndRejections (internal/process/task_queues.js:95:5)

It's being caused because one of the authors of the paper is a redirect link to another item, so the request for the resource can't follow the redirect, https://www.wikidata.org/w/index.php?title=Q43183092&redirect=no, so the "value" is "null", and then cleanAuthor can't handle null input and throws an error.

Note that a bot has fixed the redirect situation as of yesterday so the link is no longer a good test for this.

mvolz commented 1 year ago

The partial fix just skips the resource which is good if there's no RDF at all, but it's possible to actually add the author by following owl:sameAs in the rdf:

<rdf:Description rdf:about="http://www.wikidata.org/entity/Q43183092">
        <owl:sameAs rdf:resource="http://www.wikidata.org/entity/Q21391212"/>
    </rdf:Description>