Invalid URL results in internal error

Hitting any page that would 404 instead results in an internal error. I reproduced it initially with a repo name, but it also works for missing People pages and probably everything else too.

Reproduction Instructions

  1. Create a repository named test-repo
  2. Go to https://phab.example.com/source/invalid_path

Expected behavior:

You get a 404 page

Actual Behavior:
The following error is shown:

Argument 2 passed to PhabricatorMainMenuSearchView::getGlobalSearchScopeItems() must be an instance of PhabricatorApplication, null given, called in phabricator/src/view/page/menu/PhabricatorMainMenuSearchView.php on line 194

Full traceback from Apache log:

[2019-09-09 18:51:06] EXCEPTION: (TypeError) Argument 2 passed to PhabricatorMainMenuSearchView::getGlobalSearchScopeItems() must be an instance of PhabricatorApplication, null given, called in phabricator/src/view/page/menu/PhabricatorMainMenuSearchView.php on li
arcanist(), phabricator(custom=7), phutil()
  #0 phlog(TypeError) called at [<phabricator>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
  #1 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, TypeError) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:750]
  #2 AphrontApplicationConfiguration::handleThrowable(TypeError) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:339]
  #3 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:209]
  #4 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:35]

Phabricator/Arcanist Version
Internal fork last merged with stable at 2019 Week 36 (19af9d74f8c3b297a695c5eff5b05c8485d9e9bd)

Note that this repros on upstream:

https://secure.phabricator.com/source/poop

This should already be fixed in master and stable by https://secure.phabricator.com/D20792.

It’s not in stable, but I cherry-picked it from master and it seems to fix the problem. Thanks!

Ah, thanks! I actually cherry-picked it to stable this time.