Page MenuHomePhabricator

Degrade more gracefully when ProfileMenu dashboards fail to render
ClosedPublic

Authored by epriestley on Jun 23 2017, 7:11 PM.
Tags
None
Referenced Files
F13276282: D18152.diff
Fri, May 31, 5:46 AM
F13270930: D18152.id43674.diff
Wed, May 29, 2:37 PM
F13262507: D18152.diff
Mon, May 27, 2:12 AM
F13246421: D18152.diff
Thu, May 23, 10:11 AM
F13226843: D18152.diff
Sun, May 19, 11:41 PM
F13223677: D18152.diff
Sun, May 19, 4:47 AM
F13208257: D18152.id.diff
Thu, May 16, 12:20 PM
F13205696: D18152.diff
Wed, May 15, 2:17 AM
Subscribers
None

Details

Summary

Ref T12871. This replaces a dead end UI (user totally locked out) with one where the menu is still available, if the default menu item is one which generates a policy exception (e.g., because users can't see the dashboard).

Really, we should do better than this and not select this item as the default item if the viewer can't see it, but there is currently no reliable way to test for "can the viewer see this item?" so this is a more involved change. I'm thinking we get this minor improvement into the release, then pursue a more detailed fix afterward.

Test Plan
  • Added a dashboard as the top item in the global menu.
  • Changed the dashboard to be visible to only user B.
  • Viewed Home as user A.
  • Before patch: entire page is a policy exception dialog.
  • After patch, things are better:

Screen Shot 2017-06-23 at 12.06.40 PM.png (1×1 px, 134 KB)

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Wording nit.

src/applications/search/engine/PhabricatorProfileMenuEngine.php
245

/s/Render/Display/?

Also, as a general style question, what's the reason we always catch Exception instead of a more-specific subclass?

This revision is now accepted and ready to land.Jun 23 2017, 7:17 PM
src/applications/search/engine/PhabricatorProfileMenuEngine.php
245

I think we generally use fairly specific, technical language like "render" elsewhere -- in theory, our users are very technical. I probably wouldn't use the word "render" if we were consumer-facing.

Here, I think "render" is technically more accurate: we encountered a problem while trying to render a view from the dashboard object. My intent here isn't "We're Refusing To Show This To You", but "We Tried To Build This, It Didn't Work".

I'm catching Exception here because my goal is to keep the navigation menu on screen if any problem occurs while rendering the dashboard. Prior to this change, the page looked like this:

Screen Shot 2017-06-23 at 12.21.53 PM.png (1×1 px, 114 KB)

Specifically, the user is stranded without a menu.

We could catch just PhabricatorPolicyException to solve exactly this policy issue, but I want to show the menu no matter why the dashboard failed, since losing the menu is pretty confusing.

It's also (almost always) safe in this codebase to catch Exception: we do not (usually) use exceptions for control flow, so this can't (normally) accidentally catch some kind of "pseudo-exception" which should reach top level. This isn't always entirely true -- for example, the "High Security" MFA check stuff does use control flow exceptions through a couple of levels of the stack -- but is close enough to true in practice.

This revision was automatically updated to reflect the committed changes.