nathanwoulfe / Plumber

The workflow solution for Umbraco 7
39 stars 20 forks source link

Can't access Plumber backoffice section after install due to NullReferenceException #114

Closed mwanchap closed 4 years ago

mwanchap commented 5 years ago

Describe the bug After installing Plumber in a local dev instance of our site (SQL express, local IIS, mock APIs etc) and logging into Umbraco backoffice as admin, clicking the Plumber icon results in one of Umbraco's server error overlay/sidebar things appearing on the right side of the screen, containing the following:

An error occured Object reference not set to an instance of an object.

Exception Details System.NullReferenceException: Object reference not set to an instance of an object.

Stacktrace at Umbraco.Web.Trees.ApplicationTreeExtensions.TryLoadFromControllerTree(ApplicationTree appTree, String id, FormDataCollection formCollection, HttpControllerContext controllerContext) at Umbraco.Web.Trees.ApplicationTreeController.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- (I've removed the rest of the stacktrace as it's just System.Runtime calls all the way down)

This appears to have come in response from a call to /umbraco/backoffice/UmbracoTrees/ApplicationTree/GetApplicationTrees?application=workflow&tree=&isDialog=false

The left navigation menu is blank so I'm guessing that's a symptom of this error, and is hopefully where I was supposed to find the rest of Plumber's UI elements, which would hopefully explain why I can't figure out how to use it (or I might just be really dense).

I've tried the following to no avail:

To Reproduce Steps to reproduce the behavior:

  1. Install-Package Workflow.Umbraco
  2. Rebuild and restart the site
  3. Login to Umbraco backoffice as an admin user
  4. Click the Plumber icon in the menu
  5. Kaboom, error time

I have to head off really soon but I'll try to reproduce this on a blank Umbraco instance first chance I get tomorrow.

Expected behavior Was expecting some more Plumber UI elements to load, and to have access to configuration, workflow creation etc.

Screenshots https://pasteboard.co/IvEQFEK.png

Desktop (please complete the following information):

Plumber version 1.1.10

Umbraco version 7.15.0

Additional context I'm fairly sure all of the below are secondary symptoms of the main issue, but I'll describe the other symptoms anyway, in case they provide any context...

There's a note at the bottom of the Plumber section saying "Workflow not configured. Please ensure a workflow has been set on the content nodes listed below:" with a list of root nodes in the site. When I go to the content section and select "Workflow configuration" for those nodes, I can't seem to do anything as the only clickable elements are an empty picklist under "Content approval flow" and an "Add group" button which does nothing. Clicking the picklist throws these errors into the console:

TypeError: Cannot read property 'permissions' of undefined at c.add (workflow.js?cdv=2141060248:1101)

Failed to load resource: the server responded with a status of 404 (Not Found) (which came from /umbraco/backoffice/api/workflow/instancesrange/28)

There's also an enormous javascript error in the console, but I'm pretty sure that's caused by the issue described above and will probably disappear once the main issue is resolved. It says

RangeError: Maximum call stack size exceeded at _typeof (workflow.js?cdv=2141060248:12) (the above lines repeats thousands of times) at workflow.js?cdv=2141060248:168

nathanwoulfe commented 5 years ago

Hi Matt, I have a feeling that's all probably due to a dud build - I've been largely consumed with getting a V8 build out the door, so probably missed something here.

Will have a poke around as soon as I can.

mwanchap commented 5 years ago

Thanks for the quick response! I'll try a couple of previous versions and let you know how that goes.

On Tue, Sep 3, 2019, 17:20 Nathan Woulfe notifications@github.com wrote:

Hi Matt, I have a feeling that's all probably due to a dud build - I've been largely consumed with getting a V8 build out the door, so probably missed something here.

Will have a poke around as soon as I can.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nathanwoulfe/Plumber/issues/114?email_source=notifications&email_token=AASKYTVDR7HKJBEGZAHFHR3QHYF4JA5CNFSM4ITCWHP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5XIOYI#issuecomment-527337313, or mute the thread https://github.com/notifications/unsubscribe-auth/AASKYTRBS7RBW42P6PNX55DQHYF4JANCNFSM4ITCWHPQ .

nathanwoulfe commented 5 years ago

No worries. Is your site using any custom OWIN / DI stuff? Have had issues in the past with OWIN...

mwanchap commented 5 years ago

Yes to both of those, and yeah we've also had issues with OWIN / Katana (unrelated to this one). Just retried with Plumber versions 1.1.9 and 1.1.8, both with the same result, so I doubt it's a dud build. Any idea how I can debug this or get more info somehow?

Interestingly, I accidentally refreshed the /umbraco#/workflow page after uninstalling and still received the same error (in addition to all the obvious 404s), which makes me wonder if perhaps something isn't installing correctly, or is being prevented from executing etc

nathanwoulfe commented 5 years ago

I remember having OWIN-related issues in the past, but can't find/remember what it was... Will keep looking, and will spin up a clean 1.1.10 on 7.15.2 tomorrow

mwanchap commented 5 years ago

Plumber 1.1.10 works flawlessly on a fresh Umbraco 7.15.3 install. Must be something up with our project in particular. Bummer! Do you think it'd be viable to try running from source to catch an exception, or can I turn on some extra logging somewhere etc?

nathanwoulfe commented 5 years ago

I won't lie, I'm glad to hear that, for purely selfish reasons! I'll keep digging for the owin related stuff, I'm sure there was a simple fix.

mwanchap commented 5 years ago

What I've been asked to build is more of a stale-content-review process, almost exactly like Plumber's approval process but triggered after some duration (e.g. 6 months) rather than at the moment of publishing. Not asking you to do this for me, but could you point me in the right direction as to how to go about accomplishing this with Plumber (or if you can think of an easier way, even better)

nathanwoulfe commented 5 years ago

I'm actually about to dismantle exactly that functionality at work - we've built a review notification system (6 monthly), which runs a task each night to find all content where the review date property has lapsed, then emails the users responsible for that content. It uses workflow groups to determine who to email, but could use a json/xml config to map user ids to node ids. From memory, it grabs content from the Examine index, checks for passed dates, then emails those users. The actual date editor on the content types is just a normal, mandatory, date picker, but we check the value on page load and set it to empty if the date has past, so the page can't be saved without resetting the value.

But... The issue we've run into after a few years is editors getting the email, updating the review date, but not actually reviewing the content. So functionally, it works nicely, but in reality it's easy for lazy editors to circumvent.

I'm planning a rebuild to integrate Google Analytics, then use pageview data to determine if a page falls below a threshold (x views in y days), then email the editor to prompt them to reconsider the content - maybe update it, maybe remove it, maybe relocate it. Will probably end up with a combination of review date and view thresholds.

It makes sense to integrate it into Plumber, but would be a v8 thing, trying to avoid adding anything substantial in 7, don't fancy maintaining two separate versions...

Can probably share some code if it would be useful.

mwanchap commented 5 years ago

If it's not too much trouble, some code would be very much appreciated, but if you have time, at the moment what I could really use is tips on

mwanchap commented 5 years ago

@nathanwoulfe how'd you go with that v8 rebuild? Also, any chances you'd be able to share some of that code you dismantled? Even just basic "Hello world" type examples showing me where to start with content review workflows would be a huge timesaver and would be very much appreciated!

nathanwoulfe commented 5 years ago

@mwanchap still chipping away at V8 - pretty big task given I need to support variant content, so one node can be in multiple workflows at a time. Have released a couple of betas, will have another soon, which should be the last before a proper release.

Haven't start pulling down the review date stuff yet, but the guts of what you'd need to do is in my previous comment - store a date on the node, run a task to find any elapsed dates, email the correct users. It's not something Plumber manages, and probably wouldn't be a quick modification. That said, if you send a request to the appropriate API endpoint, you can start a workflow programmatically, so that could be the final step after finding all the stale content - loop the collection and create a workflow process for each node...

mwanchap commented 4 years ago

Had another crack at this and finally sorted it out with a nudge in the right direction from this post over in the Our forums. As you said, it was a DI issue - the DI container (Autofac) didn't have the Workflow assembly registered so it failed to get an instance of it for something or other. The solution was to add the following line to our DI container setup:

builder.RegisterApiControllers(typeof(Workflow.Controllers.OfflinePreviewController).Assembly);

Although from what you said about your review workflow being outside of Plumber anyway, there's probably not much need for me to actually use Plumber in the first place. Would be much easier to just make a little custom dashboard listing stale content. Oh well, at least I accomplished something

nathanwoulfe commented 4 years ago

haha, something is always better than nothing! DI is great when it's great, when it's not it can be a pain in the ass.

rasolo commented 3 years ago

Dude thanks for this issue! I would have just given up probably. I could just copy and paste the solution