Issues with a couple of Translators (Clinical Key, ORCID, CSL JSON)

I noticed the Clinical Key translator that I recently updated fails when trying to import journal articles. As I attempted to determine where the bug in the Clinical Key translator was, I found the ORCID translator was silently failing. Both seem to involve errors with the CSL JSON translator, but for separate reasons.

I'm not sure if this forum is where it is best that I detail what I've found (and ask for help in figuring out how to fix it, as I'm close but still don't understand the issue). I could post on Github or the zotero-dev google group if this is preferable.
  • this is the right place. Specific URLs would be helpful, if you don't mind?
  • The ORCID Translator relies on the CSL JSON translator to parse the information. The problem is that the API it is using doesn't return a JSON formatted string. Instead, it returns an XML formatted record.

    For example, if I go to the test cases contained within the ORCID.js translator (http://orcid.org/0000-0003-0902-4386) and try to import a record, nothing will appear in my library collection and the pop-up window in the lower left corner of my screen fails to register an error.

    An example API request for a record off of the above page is https://pub.orcid.org/v2.0_rc2/0000-0003-0902-4386/work/25382907

    On my machine (Win 7, Chrome) that address automatically downloads a numbered file (w/o extension). If you open the file in a text editor, it is an XML file. When the CSL JSON parser receives the string, it fails to parse it (as it isn't JSON). What I don't understand is that the translator clearly fails to raise an error when there should be one - it is built into the parseInupt function. But when I look at my Zotero Connector debug log, it reads:

    3)(+0000000): Translate: Beginning translation with CSL JSON

    (3)(+0000000): [object Object] {}

    (3)(+0000000): Translate: Translation successful

    (5)(+0000000): Translate: Running handler 0 for done

    (3)(+0000000): Translate: Translation successful

    (5)(+0000016): Translate: Running handler 0 for done
  • System Info (as it may be helpful): Windows 7, Typically use the Chrome Connector with Zotero Standalone, Working with Zotero 5.0 Database

    The Clinical Key problem is a bit more complicated (I think) than the ORCID issue.

    There are two strategies used in this translator: one for books and one for journal articles. The book strategy uses an ISBN search for the metadata. This component still works fine.

    The Journal Article method scrapes a "PII" identifier and queries it through the Crossref API. The returned result is then passed to the CSL JSON translator. This is where things are broken.

    After attempting to import a journal article, the Chrome Connector debug log contains the following code:

    -----------------------------------------------------------
    (4)(+0346631): Translate: Parsing code for Clinical Key (a55463ba-e403-415b-80d4-284d5f9b4b15, 2017-02-08 05:45:00)

    (3)(+0000004): Translate: Beginning translation with Clinical Key

    (3)(+0000002): Translate: monitorDOMChanges can only be called during the 'detect' stage

    (3)(+0000003): [object Object] {}

    (3)(+0000001): Translate: resolving URL http://api.crossref.org/works?query=S0016508516343244

    (3)(+0000002): Translate: resolved to http://api.crossref.org/works?query=S0016508516343244

    (3)(+0000003): HTTP GET http://api.crossref.org/works?query=S0016508516343244

    (3)(+0000002): HTTP POST {} to http://127.0.0.1:23119/connector/getSelectedCollection

    (3)(+0000007): Connector: Method getSelectedCollection succeeded

    (3)(+0000086): Translate: Creating translate instance of type import in sandbox

    (4)(+0000003): Translate: Binding sandbox to https://www.clinicalkey.com/#!/content/journal/1-s2.0-S0016508516343244

    (4)(+0000002): Translate: Parsing code for CSL JSON (bc03b4fe-436d-4a1f-ba59-de4d2d7a63f7, 2016-09-02 17:30:00)

    (3)(+0000002): Translate: Beginning translation with CSL JSON

    (2)(+0000004): Translate: Translation using CSL JSON failed:
    string => TypeError: Right-hand side of 'instanceof' is not an object
    stack => TypeError: Right-hand side of 'instanceof' is not an object
    at Zotero.Utilities.Translate.itemFromCSLJSON (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/utilities.js:1649:27)
    at Function.itemFromCSLJSON (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/inject/translate_inject.js:82:17)
    at doImport (eval at eval (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/inject/translate_inject.js:50:4), :63:6)
    at Zotero.Translate.Import._translateTranslatorLoaded (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:1222:29)
    at chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:1195:54
    at initCallback (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:2049:17)
    at Zotero.Translate.IO.String.init (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:2545:4)
    at Zotero.Translate.Import._loadTranslatorPrepareIO (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:2076:12)
    at chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:2032:6
    at Zotero.Translate.Import._loadTranslator (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:1574:16)
    url => undefined
    downloadAssociatedFiles => true
    automaticSnapshots => true

    (5)(+0000003): Translate: Running handler 0 for error

    (2)(+0000002): Translate: Translation using Clinical Key failed:
    string => TypeError: Right-hand side of 'instanceof' is not an object
    stack => TypeError: Right-hand side of 'instanceof' is not an object
    at Zotero.Utilities.Translate.itemFromCSLJSON (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/utilities.js:1649:27)
    at Function.itemFromCSLJSON (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/inject/translate_inject.js:82:17)
    at doImport (eval at eval (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/inject/translate_inject.js:50:4), :63:6)
    at Zotero.Translate.Import._translateTranslatorLoaded (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:1222:29)
    at chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:1195:54
    at initCallback (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:2049:17)
    at Zotero.Translate.IO.String.init (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:2545:4)
    at Zotero.Translate.Import._loadTranslatorPrepareIO (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:2076:12)
    at chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:2032:6
    at Zotero.Translate.Import._loadTranslator (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/zotero/translation/translate.js:1574:16)
    url => https://www.clinicalkey.com/
    downloadAssociatedFiles => true
    automaticSnapshots => true

    (5)(+0000002): Translate: Running handler 0 for done

    (5)(+0000004): Translate: Running handler 0 for done

    ---------------------------------------------------------

    It seems that the CrossRef API query works properly and the return data is passed to the CSL JSON translator. I have checked the query results manually and they look fine. (Plus, prior to passing the JSON to the CSL translator, the Clinical Key translator checks the JSON format)

    I have tried this in a Firefox Nightly Build with the Firefox connector to my 5.0 build. It produces a similar result.

    Next, I created a separate Firefox profile in a nightly build and ran the current github build of the zotero 4.0 branch. When I try to import a journal article from Clinical Key, it works perfectly.

    In the 4.0 setting, I also tested the Clinical Key translator in Scaffold and (not surprisingly) it worked.

    So perhaps this issue lies within the CSL JSON translator or in how the Connector handles the translator(s). Specifically, I believe that the line of code causing the problem is https://github.com/zotero/translators/blob/master/CSL JSON.js#L45

    Thanks for any help on resolving the issue.
  • Just incase it helps (although it is somewhat redundant), here is the error produced from Firefox:
    ----------------------------------------
    (2)(+0000002): Translate: Translation using CSL JSON failed:
    string => TypeError: invalid 'instanceof' operand Zotero.Item
    stack => Zotero.Utilities.itemFromCSLJSON@resource://gre/modules/ExtensionContent.jsm -> moz-extension://e5d1a2b2-2b7e-48d5-80ac-b655dc5f4671/zotero/utilities.js:1796:7
    Zotero.Translate.SandboxManager.prototype.importObject/attachTo[key]</<@resource://gre/modules/ExtensionContent.jsm -> moz-extension://e5d1a2b2-2b7e-48d5-80ac-b655dc5f4671/inject/translate_inject.js:89:14
    doImport@resource://gre/modules/ExtensionContent.jsm -> moz-extension://e5d1a2b2-2b7e-48d5-80ac-b655dc5f4671/inject/translate_inject.js line 63 > eval:63:3
    rest@resource://gre/modules/ExtensionContent.jsm -> moz-extension://e5d1a2b2-2b7e-48d5-80ac-b655dc5f4671/zotero/translation/translate.js:1371:24
    Zotero.Translate.Base.prototype._translateTranslatorLoaded</<@resource://gre/modules/ExtensionContent.jsm -> moz-extension://e5d1a2b2-2b7e-48d5-80ac-b655dc5f4671/zotero/translation/translate.js:1361:34
    -----------------------------------------------

    Again, it points to the same line of code in CSL JSON
  • @adomasven do you happen to know in instanceof is somehow not usable in the 5.0 connectors and/or Zotero 5.0?

    @mtd91429 you're misinterpreting the error on ORCID -- the translator sends an accept header along with the API request and with that, you get CSL JSON: Try this with
    curl -LH "Accept: application/vnd.citationstyles.csl+json" https://pub.orcid.org/v2.0_rc2/0000-0003-0902-4386/work/25382907
    to see

    So these are actually both the same issue

  • Ah - you're right about the accept header, I did miss that. Sorry.

    However, I'm not sure if I agree that they're the same issue (but I may very well be wrong). To me, the fact that the ORCID translator fails to throw the same error as the Clinical Key translator (and actually reports a successful translation) indicates that something else must be going on.

    Then again, I don't have an alternative explanation...
  • Yep, that's a bug in the connectors. A fix to follow soon. Thanks for reporting.
  • edited May 9, 2017
    @mtd91429 The firefox connector has been updated and we'll get around to chrome at some point too. Tell us if you're still seeing bug, since I did not have access to the Clinical Key publications, but fixed the problems with ORCID.
Sign In or Register to comment.