Page MenuHomePhabricator

Listing tickets "Closed By: Current Viewer" while logged out causes PhabricatorTypeaheadInvalidTokenException: This datasource ("PhabricatorPeopleUserFunctionDatasource") can not evaluate the function "viewer(...)".
Open, LowPublicBUG REPORT

Description

Upstreamed as https://we.phorge.it/T15704

While logged out, listing resolved tickets errors:

Unhandled Exception ("PhabricatorTypeaheadInvalidTokenException")
This datasource ("PhabricatorPeopleUserFunctionDatasource") can not evaluate the function "viewer(...)".

 [2023-08-14 13:58:57] EXCEPTION: (PhabricatorTypeaheadInvalidTokenException) This datasource ("PhabricatorPeopleUserFunctionDatasource") can not evaluate the function "viewer(...)". at [<phabricator>/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php:497]
 arcanist(), ava(), phabricator(), translations(), wmf-ext-misc()
   #0 <#2> PhabricatorTypeaheadDatasource::parseFunction(string) called at [<phabricator>/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php:280]
   #1 <#2> PhabricatorTypeaheadDatasource::renderTokens(array) called at [<phabricator>/src/view/form/control/AphrontFormTokenizerControl.php:76]
   #2 <#2> AphrontFormTokenizerControl::renderInput() called at [<phabricator>/src/view/form/control/AphrontFormControl.php:172]
   #3 <#2> phutil_tag(string, array, array) called at [<phabricator>/src/view/form/PHUIFormLayoutView.php:54]
   #4 <#2> PHUIFormLayoutView::render() called at [<phabricator>/src/view/form/AphrontFormView.php:160]
   #5 <#2> phutil_escape_html(AphrontFormView) called at [<phabricator>/src/infrastructure/markup/render.php:97]
   #6 <#2> phutil_tag(string, array, AphrontFormView) called at [<phabricator>/src/view/phui/PHUIObjectBoxView.php:245]
   #7 <#2> PHUIObjectBoxView::getTagContent() called at [<phabricator>/src/view/AphrontTagView.php:161]
   #8 <#2> AphrontTagView::render() called at [<phabricator>/src/view/AphrontView.php:222]
   #9 <#2> AphrontView::producePhutilSafeHTML() called at [<phabricator>/src/infrastructure/markup/render.php:115]
   #10 <#2> phutil_escape_html(PHUIObjectBoxView) called at [<phabricator>/src/infrastructure/markup/render.php:139]
   #11 <#2> phutil_escape_html(array) called at [<phabricator>/src/infrastructure/markup/render.php:171]
   #12 <#2> phutil_implode_html(string, array) called at [<phabricator>/src/view/page/PhabricatorBarePageView.php:58]
   #13 <#2> PhabricatorBarePageView::willRenderPage() called at [<phabricator>/src/view/page/PhabricatorStandardPageView.php:217]
   #14 <#2> PhabricatorStandardPageView::willRenderPage() called at [<phabricator>/src/view/page/AphrontPageView.php:46]
   #15 <#2> AphrontPageView::render() called at [<phabricator>/src/view/page/PhabricatorStandardPageView.php:911]
   #16 <#2> PhabricatorStandardPageView::produceAphrontResponse() called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:722]
   #17 <#2> AphrontApplicationConfiguration::produceResponse(AphrontRequest, PhabricatorStandardPageView) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:299]
   #18 phlog(PhabricatorTypeaheadInvalidTokenException) called at [<phabricator>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
   #19 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, PhabricatorTypeaheadInvalidTokenException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:751]
   #20 AphrontApplicationConfiguration::handleThrowable(PhabricatorTypeaheadInvalidTokenException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:337]
   #21 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:204]
   #22 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:35]

cf. old upstream https://secure.phabricator.com/T11606

Event Timeline

Aklapper renamed this task from Listing resolved tickets causes PhabricatorTypeaheadInvalidTokenException while logged out to Listing resolved tickets while logged out causes PhabricatorTypeaheadInvalidTokenException: This datasource ("PhabricatorPeopleUserFunctionDatasource") can not evaluate the function "viewer(...)"..Mar 10 2019, 9:47 AM
Aklapper renamed this task from Listing resolved tickets while logged out causes PhabricatorTypeaheadInvalidTokenException: This datasource ("PhabricatorPeopleUserFunctionDatasource") can not evaluate the function "viewer(...)". to Listing tickets "Closed By: Current Viewer" while logged out causes PhabricatorTypeaheadInvalidTokenException: This datasource ("PhabricatorPeopleUserFunctionDatasource") can not evaluate the function "viewer(...)"..Mar 10 2019, 9:50 AM
Aklapper edited projects, added Phabricator (Upstream); removed Phabricator.

Confirming; thanks for reporting this.

Note that the query has "Closed By: Current Viewer" set. Same behavior in upstream.

Aklapper triaged this task as Lowest priority.Mar 10 2019, 11:11 AM
Aklapper raised the priority of this task from Lowest to Low.Oct 27 2023, 10:04 AM
Aklapper updated the task description. (Show Details)
Aklapper changed the subtype of this task from "Task" to "Bug Report".
  1. Go to http://phorge.localhost/maniphest/query/advanced/
  2. Set "Closed By" to "Current Viewer" and Search.
  3. Open the resulting query URL in an incognito window without being logged into Phorge.

A quick hack to provide a better error message is below, however that ignores the abstraction model not to special-case child classes in the parent's parent class.

diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
index a35a8e8f0f..3a99443fac 100644
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
+++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
@@ -498,6 +498,10 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject {
 
     if (!$this->canEvaluateFunction($function)) {
       if (!$allow_partial) {
+        if (get_class($this) === "PhabricatorPeopleUserFunctionDatasource" && !$this->getViewer()->isLoggedIn()) {
+          throw new PhabricatorTypeaheadInvalidTokenException(
+            pht('You must log in to use a query which sets the current viewer as a query parameter.'));
+        }
         throw new PhabricatorTypeaheadInvalidTokenException(
           pht(
             'This datasource ("%s") can not evaluate the function "%s(...)".',
Aklapper moved this task from Backlog to Upstreamed on the Phabricator (Upstream) board.
Aklapper updated the task description. (Show Details)