Bug 377401 - KBibTeX fails to load zotero bibliography
Summary: KBibTeX fails to load zotero bibliography
Status: RESOLVED FIXED
Alias: None
Product: KBibTeX
Classification: Applications
Component: Network/online search (show other bugs)
Version: 0.6
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Thomas Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-09 00:19 UTC by Tobias Schula
Modified: 2017-03-19 20:15 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 0.6.2


Attachments
New crash information added by DrKonqi (5.48 KB, text/plain)
2017-03-09 00:40 UTC, Tobias Schula
Details
More debug output before error dialog "KBibTeX failed to retrieve the bibliography from Zotero." (1.04 KB, patch)
2017-03-09 21:04 UTC, Thomas Fischer
Details
output after applying the patch from comment 3 (1.78 KB, text/plain)
2017-03-09 22:28 UTC, Tobias Schula
Details
Append API key to all Zotero queries to allow retrieving data in multiple steps (6.29 KB, patch)
2017-03-10 21:47 UTC, Thomas Fischer
Details
Patch that combines all fixes for issues report in this bug report and its comments (up to #6) (10.78 KB, patch)
2017-03-12 13:17 UTC, Thomas Fischer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Schula 2017-03-09 00:19:00 UTC
Overview: 
Loading a zotero bibliography fails with the following error message: "KBibTeX failed to retrieve the bibliography from Zotero. Please check that the provided user id and API key are valid."
But it shows my zotero library in the library tab, so number and API key should be correct.

Steps to Reproduce: 
    1) Type in zotero credentials

    2) Select "load bibliography" button

Actual Results: 
Error message: KBibTeX failed to retrieve the bibliography from Zotero. Please check that the provided user id and API key are valid.

Expected Results: 
KBibTeX should load my zotero bibliography

Build Date & Platform: 
Version 0.6.0.96-10.1-x86_64

Additional Information: My zotero library has about 300 entries and is about 400MB big
Comment 1 Tobias Schula 2017-03-09 00:40:12 UTC
Created attachment 104465 [details]
New crash information added by DrKonqi

kbibtex (0.6.0.96) on KDE Platform 4.14.25 using Qt 4.8.6

- What I was doing when the application crashed:
After double clicking on the folders in my zotero library, KBibTeX crashed

-- Backtrace (Reduced):
#11 0x00007fa644eb1900 in File::~File (this=0x36906a0, __in_chrg=<optimized out>) at /usr/src/debug/kbibtex-0.6.0.96/src/data/file.cpp:104
#12 0x00007fa6455aa6d2 in Zotero::Items::finishedFetchingItems (this=0x3797920) at /usr/src/debug/kbibtex-0.6.0.96/src/networking/zotero/items.cpp:116
#13 0x00007fa6455696e5 in Zotero::Items::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at /usr/src/debug/kbibtex-0.6.0.96/build/src/networking/moc_items.cpp:55
[...]
#17 0x00007fa642c8e48e in QObject::event(QEvent*) () from /usr/lib64/libQtCore.so.4
#18 0x00007fa6431bb6fc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4
Comment 2 Thomas Fischer 2017-03-09 21:03:09 UTC
You are reporting two related but different problems.

About the crash in comment #1: I think I have fixed this problem in commit 914cea6a733f900 (branch 'kbibtex/0.6'). I am not sure about the reason, but the problem is reproducible only with clang, but not gcc (in my test setup).

About the error message in your original posting: The message box is shown if certain test, composed of various checks, fails. To trace the problem, please apply the patch I am going to attach on the latest code from branch 'kbibtex/0.6', compile it with full debug settings [1], install it in a temporary directory [1], and then launch KBibTeX from a console. I would like to see the complete output you get on the console when you try to access your Zotero bibliography.

[1] https://userbase.kde.org/KBibTeX/Development
Comment 3 Thomas Fischer 2017-03-09 21:04:04 UTC
Created attachment 104475 [details]
More debug output before error dialog "KBibTeX failed to retrieve the bibliography from Zotero."
Comment 4 Tobias Schula 2017-03-09 22:28:11 UTC
Created attachment 104476 [details]
output after applying the patch from comment 3

It doesn't crash anymore when double clicking the library. And this is the output I get after applying the patch. This seems to be the interesting part:
> "Error downloading https://api.zotero.org/users/2535537/tags?start=45&limit=45 - server replied: Forbidden"
Comment 5 Thomas Fischer 2017-03-10 21:47:45 UTC
Created attachment 104502 [details]
Append API key to all Zotero queries to allow retrieving data in multiple steps

Please revert the patch 104475, i.e. get a clean checkout from branch 'kbibtex/0.6' (commit 914cea6a733 at the time of writing), before applying this new patch.
Comment 6 Tobias Schula 2017-03-10 22:41:11 UTC
Thanks a lot! I can now load my zotero library and import entries. However, the search results panel doesn't open when I double click on the zotero library. It only shows results if I did an online search before and when the search panel is opened. If I close the search panel it doesn't appear when double clicking the library. Is that expected behavior or should I open a separate bug?
Comment 7 Thomas Fischer 2017-03-12 13:17:35 UTC
Created attachment 104513 [details]
Patch that combines all fixes for issues report in this bug report and its comments (up to #6)

To apply this patch, first revert back to a clean checkout of branch 'kbibtex/0.6'. This patch combines all changes proposed so far.

Please check if all issues reported so far (up to and including comment 6) have been fixed, including but not limited browsing large collections on Zotero as well as opening the Search Results docklet for any results found.
Comment 8 Tobias Schula 2017-03-16 19:38:34 UTC
Thank you! It loads now the zotero library without problems and when double clicking the library it also opens the search results docklet. I can import without problems and I notice no lag when browsing my zotero library.
Comment 9 Thomas Fischer 2017-03-19 20:15:33 UTC
Git commit f5dd33c428ca629a8de3c41e90bbe86ce8fad588 by Thomas Fischer.
Committed on 16/03/2017 at 22:16.
Pushed by thomasfischer into branch 'kbibtex/0.6'.

Appending API key to all requests to Zotero

Appending API key is relevant for answers from Zotero that
span multiple requests, where the response contains a
"next related page" URL. This URL omits the API key which
needs to be appended to make a valid, authenticated request
to Zotero."

M  +14   -3    src/networking/zotero/api.cpp
M  +7    -1    src/networking/zotero/api.h
M  +2    -1    src/networking/zotero/collection.cpp
M  +2    -1    src/networking/zotero/groups.cpp
M  +2    -1    src/networking/zotero/items.cpp
M  +2    -1    src/networking/zotero/tags.cpp

https://commits.kde.org/kbibtex/f5dd33c428ca629a8de3c41e90bbe86ce8fad588
Comment 10 Thomas Fischer 2017-03-19 20:15:33 UTC
Git commit e26e3a2ea3fc7b675e997521dae4de463b02a5da by Thomas Fischer.
Committed on 16/03/2017 at 22:17.
Pushed by thomasfischer into branch 'kbibtex/0.6'.

Merge branch 'bugs/kde377401' into kbibtex/0.6
FIXED-IN: 0.6.2


https://commits.kde.org/kbibtex/e26e3a2ea3fc7b675e997521dae4de463b02a5da
Comment 11 Thomas Fischer 2017-03-19 20:15:33 UTC
Git commit 8cc77ba12521d9890584a74793b15d77f44cf269 by Thomas Fischer.
Committed on 16/03/2017 at 22:16.
Pushed by thomasfischer into branch 'kbibtex/0.6'.

Showing search results docklet on data returned from Zotero

Fixing a minor issue as reported in comment 6 of
KDE bug report 377401:

"However, the search results panel doesn't open when I
double click on the zotero library. It only shows
results if I did an online search before and when the
search panel is opened. If I close the search panel
it doesn't appear when double clicking the library."

M  +2    -1    src/program/docklets/zoterobrowser.cpp
M  +4    -1    src/program/docklets/zoterobrowser.h
M  +2    -1    src/program/mainwindow.cpp

https://commits.kde.org/kbibtex/8cc77ba12521d9890584a74793b15d77f44cf269