JabRef / JabRef-Browser-Extension

Browser extension for JabRef to allow importing of new items directly from the browser.
https://www.jabref.org/
GNU Affero General Public License v3.0
84 stars 22 forks source link

Error while sending to JabRef: TypeError: data is undefined #158

Closed mj-ramirez closed 3 years ago

mj-ramirez commented 4 years ago

TypeError: data is undefined at moz-extension://29a9afa2-0573-4141-8928-14bab21b3198/Zotero/translate_item.js:134 zotero.js:335:12

JabRef: Got task to convert
Array [ {…} ] to BibTeX bibtexConverter.js:234:11 JabRef: Convert items to BibTeX:
Array [ {…} ] bibtexConverter.js:2:10

OSX High Sierra Firefox 74.0 Jabref 5.0 (Remote 6050 on)

M4lF3s commented 4 years ago

Experiencing the same behavior on Linux: Firefox 74.0 OpenSUSE Tumbleweed JabRef 5.0

With the Developer Edition of Firefox (version 75.0b12) it is working though.

mj-ramirez commented 4 years ago

I have tried Developer Edition of Firefox (version 75.0b12) on OSX High Sierra: no luck! Same error message.

tobiasdiez commented 4 years ago

Do you have this with every item upon import or only on specific websites?

mj-ramirez commented 4 years ago

it affects all items, regardless of website. The "Bibit Now!" extension works (not sure if that helps)

MJR

borgch commented 4 years ago

The same error on Archlinux (for example, on page https://arxiv.org/abs/1409.8086)

In addon settings: Attempt to postMessage on disconnected port

In web console: TypeError: data is undefined at moz-extension://c1e886ab-a241-4b09-9a50-72089de2e3fa/Zotero/translate_item.js:134 zotero.js:335:12 JabRef: Got task to convert
Array [ {…} ] to BibTeX bibtexConverter.js:234:11 JabRef: Convert items to BibTeX:
Array [ {…} ] bibtexConverter.js:2:10

Versions: Firefox 75.0 JabRef 5.1 (installed jabref-latest AUR package) JabRef Browser Extension: version from 11 April 2020

Cutuchiqueno commented 4 years ago

Here the same on Arch Linux:

Versions: Firefox 75.0 JabRef 5.0 JabRef Browser Extension: version from 19 April 2020

Haini commented 4 years ago

Same on Ubuntu 18.04 LTS:

TypeError: data is undefined at moz-extension://11800bcf-4e6c-41d6-95b6-7dd908673fa6/Zotero/translate_item.js:134 zotero.js:335:12
JabRef: Got task to convert  
Array [ {…} ]
  to BibTeX bibtexConverter.js:234:11
JabRef: Convert items to BibTeX:  
Array [ {…} ]  bibtexConverter.js:2:10

Versions: Self Compiled Jabref from commit 18ac7940298e411dee33d66d0b43dcf211c3f4ca (HEAD -> feature/downloadFilesOnImport, origin/feature/downloadFilesOnImport) (Jabref says v100.0) Firefox 75.0 JabRef Browser Extension: 2.2 (released March 17) Chrome Version 81.0.4044.122 (Official Build) (64-bit) JabRef Browser Extension: 2.1.2

The same setup works on an Ubuntu 20.04 LTS.

Haini commented 4 years ago

And I think I found the issue (for me, at least) and it's not a bug of JabRef for me.

tl;dr for Firefox cd ~/.mozilla/native-messaging-hosts/ wget https://raw.githubusercontent.com/JabRef/jabref/master/buildres/linux/native-messaging-host/firefox/org.jabref.jabref.json mkdir /opt/jabref chown USER /opt/jabref (optional) cd /opt/jabref cp CLONEDJABREF/build/image/* . -r cp CLONEDJABREF/buildres/linux/jabrefHost.py ./lib/.

So not really Jabrefs fault, although I somewhat miss those steps int the documentation.


After carefully re-following the documentation on setting up the browser plugin I noticed that I need to place org.jabref.jabref.json in ~/.mozilla/native-messaging-hosts/.

So I did that with no improvements.

After inspecting org.jabref.jabref.json closer, the following line comes to attention:

"path": "/opt/jabref/lib/jabrefHost.py",

And there is the issue. Since I built both used JabRef versions myself I never set them up in the intended way.

What I now did is copying the build results from jabref/build/image/* to /opt/jabref/. This still leaves out jabrefHost.py which is located in jabref/buildres/linux/jabrefHost.py. Copied that to /opt/jabref/lib/ and I was good to go.

husten1997 commented 4 years ago

I found a different workaround, inspired by @Haini . I'm on Firefox 80.0.1 and Manjaro, installed JabRef from the AUR, which might be the reason why the fix of Haini did not work for me.

  1. Follow the installation as described here, including the step of coping the .json file. (Or follow Hainis instructions)

  2. As Haini pointed out, the path in the .json file points to /opt/jabref/lib/jabrefHost.py. So copy the .py file as described by Haini.

  3. It still didn't work for me, so I had a look at jabrefHost.py and it additionally requires the executable in a relative path to the Script:

LyzardKing commented 4 years ago

@husten1997 The .py script will look at which jabref and use that if the relative file is not found.. so that should not be necessary. Try changing the path in the .json file to the jabrefHost.py included in jabref (so not a copy)

husten1997 commented 4 years ago

@husten1997 The .py script will look at which jabref and use that if the relative file is not found.. so that should not be necessary. Try changing the path in the .json file to the jabrefHost.py included in jabref (so not a copy)

Ah, alright I see, thank you. But: This failed for me because of two reasons, which might be due to the fact that I installed JabRef from the AUR:

  1. The .py file was not installed anywhere on my system. I had to clone it from the repo
  2. The string in line 21 of the .py file is misspelled for me, because my executable is called JabRef, so which jabref yields no result

I'll test the AUR build again on a different machine, maybe something messed up my installation.

LyzardKing commented 4 years ago

Ok. So if we get the .py file added to the AUR build (I'm not in charge of that, but we can raise the issue on the AUR page) and set the executable to the lowercase standard it should be fine. @husten1997 Could you report this on the AUR repo if you're already registered?

husten1997 commented 4 years ago

Ok I have tested all JabRef AUR repos: 1) jabref: the normal jabref repo, version 5.1 2) jabref-git: automatically build jabref from github 3) jabref-latest: latest version of Jabref on master

So 3) installed just fine, the *.py file is installed, the executable is lowercase, 1) and 2) had the issues described above. So for everyone using the AUR: use the "jabref-latest" package, it should work out of the box with the browser extension.

Regarding the reporting of the AUR issue: I am going to raise an Issue on the Arch Linux page and reference to this thread and an other issue on the maintainers github page to draw his attention to this.

michaellass commented 4 years ago

This should be fixed now for the jabref package in the AUR, as long as the user installed the json file correctly.

@tobiasdiez is there a specific reason why the org.jabref.jabref.json is not included in the browser extension? For comparison, I also use the extension for KeepassXC and a very similar file ~/.mozilla/native-messaging-hosts/org.keepassxc.keepassxc_browser.json came with the extension without the need for any manual intervention.

LyzardKing commented 4 years ago

Thanks! I'll look into it At the moment the json files are released in jabref instead of the extension to be able to tailor them to the different release methods. So the deb/tar/snap/flatpak can each have the proper path set in the json file. Another possibility would be to have the install modify the json after the fact, but what happens if the extension is installed after the main program?

EDIT: An example of this problem is the fact that the snap for keepassxc will not work unless you install another script (from their website) that changes the .json file

tobiasdiez commented 4 years ago

This file cannot be installed via the browser extension, and that's the whole point in the security concept: extension E says "I want to communicate to app A" and app A has to say "I want to allow extension E" by creating such a json file (listing extension E). In this way, no extension can communicate/access other applications outside of Firefox/Chrome without the applications affirmation.

The theory is nice, but the practice horrible as there are no detailed error information when the json file is missing, or points to missing files; the json needs to be changed for each OS / installation location etc. This sadly leads to the bad user experience, where we cannot do much than trying to setup everything correctly upon installation of JabRef (the app). So thanks a lot for fixing the AUR install scripts!

michaellass commented 4 years ago

That makes sense. Also, my memory on the KeepassXC extension was wrong. There is user action required but they implemented this in KeepassXC itself. So you can select in the preferences for which browsers the extension should work and then KeepassXC creates the json file in the user's home directory: https://github.com/keepassxreboot/keepassxc/blob/43c82ccb09f05c3a14fd6109183e442facc58e97/src/browser/NativeMessageInstaller.cpp Maybe something like this would be an option for JabRef as well.

lhietal commented 3 years ago

I had a similar error message on macOS. It was actually caused by jabrefhost.py pointing to incorrect location for python3. At least my version of macOS doesn't have python3 installed in /usr/bin. Changing this to a homebrew installation of python3 resolved the problem.

macOS 10.14.6 JabRef 5.2 Firefox 84.0.2

tobiasdiez commented 3 years ago

That's good to hear! In the next version, the "data is undefined" error should be fixed (it was actually only a stray error message, not related to the import errors). We also improved the installation scripts, so I hope it's ok to close this issue now.

@lhietal May I ask you to add a last step "Check that the Python script works" to https://github.com/JabRef/user-documentation/blob/master/en/collect/jabref-browser-extension.md. I guess just trying to run the script from the shell should display an error if e.g. the python installation is not found. Thanks!