thomasbrueggemann / paperless-desktop

šŸƒ macOS app that uses the paperless API to manage your document scans.
GNU General Public License v3.0
582 stars 52 forks source link

"Could not load documents!" #48

Open stgarf opened 5 years ago

stgarf commented 5 years ago

Expected Behavior

Expected UI to load up all documents, correspondents, and tags.

Actual Behavior

UI partially loaded the left-side nav bar then presented an error message: screen shot 2018-12-18 at 11 38 56 am

Steps to Reproduce the Problem

  1. I am using Paperless through an SSH tunnel so this is most likely where the issue is stemming from. I forward port 8000 on the remote machine locally to port 8000. ssh -NL 8000:localhost:8000 paperlessuser@192.168.1.47
  2. Paperless itself works and is fully accessible to me locally via, http://localhost:8000/
  3. I configured Paperless-desktop with this URL and my username/password and received the above error message.

Specifications

Here's some output from the debug console:

Uncaught (in promise) TypeError: Cannot read property 'id' of undefined
    at file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦D0A7D24B/d/Paperless.app/Contents/Resources/app/js/build/bundle.js:1470:34
    at Array.map (native)
    at DocumentItem.render (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦D0A7D24B/d/Paperless.app/Contents/Resources/app/js/build/bundle.js:1464:31)
    at file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75790:21
    at measureLifeCyclePerf (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75070:12)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75789:25)
    at ReactCompositeComponentWrapper._renderValidatedComponent (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75816:32)
    at ReactCompositeComponentWrapper.performInitialMount (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75356:30)
    at ReactCompositeComponentWrapper.mountComponent (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75252:21)
    at Object.mountComponent (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:81544:35)

and (very similar to the last one, except triggered by clicking the documents button)

DocumentItem.js:64 Uncaught TypeError: Cannot read property 'id' of undefined
    at file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦D0A7D24B/d/Paperless.app/Contents/Resources/app/js/build/bundle.js:1470:34
    at Array.map (native)
    at DocumentItem.render (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦D0A7D24B/d/Paperless.app/Contents/Resources/app/js/build/bundle.js:1464:31)
    at file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75790:21
    at measureLifeCyclePerf (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75070:12)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75789:25)
    at ReactCompositeComponentWrapper._renderValidatedComponent (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75816:32)
    at ReactCompositeComponentWrapper.performInitialMount (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75356:30)
    at ReactCompositeComponentWrapper.mountComponent (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:75252:21)
    at Object.mountComponent (file:///private/var/folders/09/g9nph7tx3bzdhmf9k8vj_kyr0000gn/T/AppTranslocā€¦/d/Paperless.app/Contents/Resources/app/js/build/vendor.bundle.js:81544:35)

and

ReactReconciler.js:60 Uncaught TypeError: Cannot read property 'getHostNode' of null
    at Object.getHostNode (ReactReconciler.js:60)
    at ReactCompositeComponentWrapper.getHostNode (ReactCompositeComponent.js:381)
    at Object.getHostNode (ReactReconciler.js:60)
    at Object.updateChildren (ReactChildReconciler.js:111)
    at ReactDOMComponent._reconcilerUpdateChildren (ReactMultiChild.js:204)
    at ReactDOMComponent._updateChildren (ReactMultiChild.js:308)
    at ReactDOMComponent.updateChildren (ReactMultiChild.js:295)
    at ReactDOMComponent._updateDOMChildren (ReactDOMComponent.js:944)
    at ReactDOMComponent.updateComponent (ReactDOMComponent.js:758)
    at ReactDOMComponent.receiveComponent (ReactDOMComponent.js:720)
stgarf commented 5 years ago

@thomasbrueggemann just wondering if you maybe had a chance to try this out... latest paperless docker container and latest paperless-desktop release :(.

stgarf commented 5 years ago

Okay, I finally got bothered enough to dig into javascript and electron applications :(

Looks like the bug was possibly introduced with PR #45. Seems like the return(TagDot</>); is failing here

On my local instance I made the file look as follows with this patch file and Paperless-Desktop loads properly šŸ‘ however the sidebar doesn't work properly šŸ‘Ž.

I hope this helps narrow down the issue @NickBusey @thomasbrueggemann. Thanks!

From 4169e2803ad2aeb9f6abc10cd718ed43e83edac8 Mon Sep 17 00:00:00 2001
From: Steve Garf <stgarf@gmail.com>
Date: Fri, 8 Mar 2019 05:12:23 -0800
Subject: [PATCH 1/1] Wrap failing statement in try/except block.

---
 js/src/components/DocumentItem.js | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/js/src/components/DocumentItem.js b/js/src/components/DocumentItem.js
index 9eef223..dca0da6 100644
--- a/js/src/components/DocumentItem.js
+++ b/js/src/components/DocumentItem.js
@@ -58,13 +58,17 @@ class DocumentItem extends PaperlessComponent {
                        var tagRegex = /\/([0-9]+)\//;
                        var tagId = tagRegex.exec(tagUrl)[1];
                        var tag = tags[tagId];
-                       return (
-                           <TagDot
-                               tag={tag}
-                               key={"sidebar_tags_" + tag.id}
-                               setTagFilter={this.props.setTagFilter}
-                           />
-                       );
+                       try {
+                           return (
+                               <TagDot
+                                   tag={tag}
+                                   key={"sidebar_tags_" + tag.id}
+                                   setTagFilter={this.props.setTagFilter}
+                               />
+                           );
+                       } catch (err) {
+                           console.log("An unknown error has occurred:", err);
+                       }
                    })}
                </div>
                <small>{moment(this.props.document.created).format("LLLL")}</small>
--
2.17.2 (Apple Git-113)
thomasbrueggemann commented 5 years ago

Thanks for looking into it, @stgarf . I myself are running paperless v0.0.4.

I think the underlying issue here is API changes over time in paperless. Which is perfectly fine. But paperless-desktop has no way to deal with those.

Either all users use the same version of paperless - highly unlikely, or we introduce some sort of version detection system. Any contribution is happyly welcome. I am not able to contribute such a feature at the moment, due to my lack of sparetime.

stgarf commented 5 years ago

@thomasbrueggemann Maybe in the future... but for now I'm actually working on the exact opposite of a GUI, paperless-cli :+1:.