Page MenuHomePhorge

Phorge/auth/config/view/3/ Call to phutil_nonempty_string() expected null or a string, got: PhutilSafeHTML.
Closed, ResolvedPublic

Description

When opening the config page for facebook and templating using the same form of oauth a InvalidArgumentExceptionis thrown.

A workaround can be done where the phutil_nonempty_string returns false or true within the get title call.

The html object being parsed contains the following string:

object that is causing exception.

[Thu Jan 11 14:31:13.478731 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352] arcanist(head=master, ref.master=6142fcd5264f), phorge(head=doommius/discord, ref.master=49c3fe619342, ref.doommius/discord=efcc595275e8)

Stack trace

[Thu Jan 11 14:31:13.478661 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352] [2024-01-11 15:31:13] EXCEPTION: (InvalidArgumentException) Call to phutil_nonempty_string() expected null or a string, got: PhutilSafeHTML. at [<arcanist>/src/utils/utils.php:2127]
[Thu Jan 11 14:31:13.478731 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352] arcanist(head=master, ref.master=6142fcd5264f), phorge(head=doommius/discord, ref.master=49c3fe619342, ref.doommius/discord=efcc595275e8)
[Thu Jan 11 14:31:13.478733 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #0 <#2> phutil_nonempty_string(PhutilSafeHTML) called at [<phorge>/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php:153]
[Thu Jan 11 14:31:13.478734 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #1 <#2> PhabricatorAuthProviderConfigTransaction::getTitle() called at [<phorge>/src/applications/transactions/view/PhabricatorApplicationTransactionView.php:448]
[Thu Jan 11 14:31:13.478735 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #2 <#2> PhabricatorApplicationTransactionView::renderEvent(PhabricatorAuthProviderConfigTransaction, array) called at [<phorge>/src/applications/transactions/view/PhabricatorApplicationTransactionView.php:182]
[Thu Jan 11 14:31:13.478736 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #3 <#2> PhabricatorApplicationTransactionView::buildEvents(boolean) called at [<phorge>/src/applications/transactions/view/PhabricatorApplicationTransactionView.php:230]
[Thu Jan 11 14:31:13.478737 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #4 <#2> PhabricatorApplicationTransactionView::buildPHUITimelineView() called at [<phorge>/src/applications/transactions/view/PhabricatorApplicationTransactionView.php:209]
[Thu Jan 11 14:31:13.478738 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #5 <#2> phutil_escape_html(PhabricatorApplicationTransactionView) called at [<phorge>/src/infrastructure/markup/render.php:139]
[Thu Jan 11 14:31:13.478739 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #6 <#2> phutil_escape_html(array) called at [<phorge>/src/infrastructure/markup/render.php:97]
[Thu Jan 11 14:31:13.478740 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #7 <#2> phutil_tag(string, array, array) called at [<phorge>/src/view/phui/PHUITwoColumnView.php:203]
[Thu Jan 11 14:31:13.478741 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #8 <#2> PHUITwoColumnView::buildMainColumn() called at [<phorge>/src/view/phui/PHUITwoColumnView.php:121]
[Thu Jan 11 14:31:13.478742 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #9 <#2> PHUITwoColumnView::getTagContent() called at [<phorge>/src/view/AphrontTagView.php:161]
[Thu Jan 11 14:31:13.478743 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #10 <#2> AphrontTagView::render() called at [<phorge>/src/view/AphrontView.php:222]
[Thu Jan 11 14:31:13.478744 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #11 <#2> AphrontView::producePhutilSafeHTML() called at [<phorge>/src/infrastructure/markup/render.php:115]
[Thu Jan 11 14:31:13.478745 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #12 <#2> phutil_escape_html(PHUITwoColumnView) called at [<phorge>/src/infrastructure/markup/render.php:171]
[Thu Jan 11 14:31:13.478746 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #13 <#2> phutil_implode_html(string, array) called at [<phorge>/src/view/page/PhabricatorBarePageView.php:58]
[Thu Jan 11 14:31:13.478747 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #14 <#2> PhabricatorBarePageView::willRenderPage() called at [<phorge>/src/view/page/PhabricatorStandardPageView.php:217]
[Thu Jan 11 14:31:13.478750 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #15 <#2> PhabricatorStandardPageView::willRenderPage() called at [<phorge>/src/view/page/AphrontPageView.php:46]
[Thu Jan 11 14:31:13.478752 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #16 <#2> AphrontPageView::render() called at [<phorge>/src/view/page/PhabricatorStandardPageView.php:919]
[Thu Jan 11 14:31:13.478752 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #17 <#2> PhabricatorStandardPageView::produceAphrontResponse() called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:722]
[Thu Jan 11 14:31:13.478753 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #18 <#2> AphrontApplicationConfiguration::produceResponse(AphrontRequest, PhabricatorStandardPageView) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:299]
[Thu Jan 11 14:31:13.478754 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #19 phlog(InvalidArgumentException) called at [<phorge>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
[Thu Jan 11 14:31:13.478755 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #20 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, InvalidArgumentException) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:751]
[Thu Jan 11 14:31:13.478756 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #21 AphrontApplicationConfiguration::handleThrowable(InvalidArgumentException) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:337]
[Thu Jan 11 14:31:13.478757 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #22 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:204]
[Thu Jan 11 14:31:13.478758 2024] [php:notice] [pid 169782] [client 192.168.1.173:42352]   #23 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phorge>/webroot/index.php:36]

Steps to reproduce:

  1. System config PHP version PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.2, Copyright (c) Zend Technologies with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies Apache2 Server version: Apache/2.4.52 (Ubuntu) Server built: 2023-10-26T13:44:44 Ubuntu Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy
  2. Clone repo and setup Phorge with basic config Setup Oauth2 towards Facebook. go to view config. error should be here. Might also be reproducible with other auth implementations as well.

Event Timeline

Can you try changing this line in your local install?

https://we.phorge.it/source/phorge/browse/master/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php;8e09dbfee3436cfa77dd304d060b017cc9e399ea$153

Try adopting phutil_nonempty_stringlike() that also handles objects.

If it works, feel free to propose a patch. For example running ../arcanist/bin/arc diff

Heck yeah, changing phutil_nonempty_string() to phutil_nonempty_stringlike() there fixed the issue I had mentioned in a comment in T15737: Include information for installing required PHP version in Diviner docs.