Page MenuHomePhabricator

Exception: "Call to phutil_nonempty_string() expected null or a string, got: int" in PhabricatorRepository.php (due to Importing)
Closed, ResolvedPublicBUG REPORT

Description

Upstream: https://we.phorge.it/T15640 but we need more debugging downstream first why this happens.

[2023-09-15 16:22:39] EXCEPTION: (InvalidArgumentException) Call to phutil_nonempty_string() expected null or a string, got: int. at [<arcanist>/src/utils/utils.php:2124]
 arcanist(), ava(), phorge(), translations(), wmf-ext-misc()
   #0 <#2> phutil_nonempty_string(integer) called at [<phorge>/src/applications/repository/storage/PhabricatorRepository.php:749]
   #1 <#2> PhabricatorRepository::generateURI(array) called at [<phorge>/src/applications/diffusion/request/DiffusionRequest.php:459]
   #2 <#2> DiffusionRequest::generateURI(array) called at [<phorge>/src/applications/diffusion/controller/DiffusionCommitBranchesController.php:39]
   #3 <#2> DiffusionCommitBranchesController::handleRequest(AphrontRequest) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:284]
   #4 phlog(InvalidArgumentException) called at [<phorge>/src/aphront/handler/PhabricatorAjaxRequestExceptionHandler.php:27]
   #5 PhabricatorAjaxRequestExceptionHandler::handleRequestThrowable(AphrontRequest, InvalidArgumentException) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:751]
   #6 AphrontApplicationConfiguration::handleThrowable(InvalidArgumentException) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:296]
   #7 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:204]
   #8 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phorge>/webroot/index.php:35]

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Add again temporary debug output for T347483repos/phabricator/phabricator!85aklapperT347483mmwmf/stable
Add temporary debug output for T347483repos/phabricator/phabricator!78aklapperT347483debug3wmf/stable
Revert "Add temporary debug output for T347483"repos/phabricator/phabricator!42aklapperT347483debugRevertwmf/stable
Add temporary debug output for T347483repos/phabricator/phabricator!17aklapperT347483debugwmf/stable
Customize query in GitLab

Event Timeline

Aklapper triaged this task as Low priority.

Debug output spew:

[2023-10-06 23:45:02] PHLOG: 'WMF T347483 Debug: branch name: 201709 for repo rEWIS named rEWIS' at [/srv/deployment/phabricator/deployment-cache/revs/6f19600738f01fa2e81c73681c3622773e468879/phabricator/src/applications/repository/storage/PhabricatorRepository.php:750]
[2023-10-06 23:45:02] EXCEPTION: (InvalidArgumentException) Call to phutil_nonempty_string() expected null or a string, got: int. at [<arcanist>/src/utils/utils.php:2124]

So it's because https://phabricator.wikimedia.org/diffusion/EWIS/branches/ has a branch called 201709, but still unclear how to actually trigger the error

Aklapper changed the task status from Open to Stalled.Nov 2 2023, 10:23 AM
Aklapper edited projects, added Phabricator (Upstream), Upstream; removed Phabricator.
Aklapper moved this task from Backlog to Reported Upstream on the Upstream board.
Aklapper moved this task from Backlog to Upstreamed on the Phabricator (Upstream) board.
Aklapper changed the subtype of this task from "Task" to "Bug Report".Nov 14 2023, 11:21 AM
[2023-12-11 15:55:03] PHLOG: 'WMF T347483 Debug: branch name: 178 for repo rTVTC named tool-video2commons' at [/srv/deployment/phabricator/deployment-cache/revs/0b76984ffcf6458eab10d19f52ac1f1c99b42291/phabricator/src/applications/repository/storage/PhabricatorRepository.php:750]
[2023-12-11 15:55:03] EXCEPTION: (InvalidArgumentException) Call to phutil_nonempty_string() expected null or a string, got: int. at [<arcanist>/src/utils/utils.php:2124]

is strange as no such branch exists.

Looking at the Apache 2 accesslog dashboard in Logstash checking for url.query containing video2commons, and filtering by client.ip, I see that https://phabricator.wikimedia.org/rTVTCed94556668b40091bc817e30e1ce1bf027edb820 was accessed, but exact steps afterwards remain unclear, no matter what I'm clicking in the UI.

Added more debug spew in https://phabricator.wikimedia.org/rPHAB33085e34e38eba65869cffcbbfb5ea5a5d7fd2f1 but need to check logs after 2024-03-17 (no occurrence yet)

Aklapper changed the task status from Stalled to Open.EditedMay 10 2024, 7:02 PM

Reading the code a bit more, I found a reproducer.

Go to any commit in the affected branch at https://phabricator.wikimedia.org/diffusion/EWIS/history/201709/ , for example https://phabricator.wikimedia.org/rEWISfe34de01efd254558f0ba356cad4a146e09da4ec :
The Branches field says Loading... (that's is only an outcome and not a reason though) due to the code in ./webroot/rsrc/js/application/diffusion/behavior-commit-branches.js: for (var uri in config) { JX.DOM.setContent(JX.$(config[uri]), 'Loading...'); ...

May want to ./bin/repository reparse --importing --all --trace R1911 if we feel adventurous.

Aklapper renamed this task from Exception: "Call to phutil_nonempty_string() expected null or a string, got: int" in PhabricatorRepository.php to Exception: "Call to phutil_nonempty_string() expected null or a string, got: int" in PhabricatorRepository.php (due to Importing).Aug 2 2024, 9:58 PM

Got another occurrence in the logs recently:
https://phabricator.wikimedia.org/diffusion/OSWB/branches/master/.gitignore;5a588bf0ee10546ddb9d0872d1be1bf48b3f3c07 triggers this error directly (though Ref "master" does not exist in this repository) but same issue can be triggered by using an existing branch:

The revision itself at https://phabricator.wikimedia.org/rOSWB5a588bf0ee10546ddb9d0872d1be1bf48b3f3c07 does exist and the file https://phabricator.wikimedia.org/diffusion/OSWB/browse/main/.gitignore also exists.

Call stack is a bit different though:

[2024-11-21 19:19:11] EXCEPTION: (InvalidArgumentException) Call to phutil_nonempty_string() expected null or a string, got: int. at [<arcanist>/src/utils/utils.php:2128]
arcanist(), ava(), phorge(), translations(), wmf-ext-misc()
  #0 <#2> phutil_nonempty_string(integer) called at [<phorge>/src/applications/repository/storage/PhabricatorRepository.php:752]
  #1 <#2> PhabricatorRepository::generateURI(array) called at [<phorge>/src/applications/diffusion/request/DiffusionRequest.php:459]
  #2 <#2> DiffusionRequest::generateURI(array) called at [<phorge>/src/applications/diffusion/view/DiffusionBranchListView.php:80]
  #3 <#2> phutil_tag(string, array, array) called at [<phorge>/src/infrastructure/javelin/markup.php:70]
  #4 <#2> phutil_escape_html(array) called at [<phorge>/src/infrastructure/markup/render.php:139]
  #5 <#2> phutil_escape_html(array) called at [<phorge>/src/infrastructure/markup/render.php:97]
  #6 <#2> phutil_tag(string, array, array) called at [<phorge>/src/view/phui/PHUITwoColumnView.php:242]
  #7 <#2> PHUITwoColumnView::buildFooter() called at [<phorge>/src/view/phui/PHUITwoColumnView.php:123]
  #8 <#2> PHUITwoColumnView::getTagContent() called at [<phorge>/src/view/AphrontTagView.php:161]
  #9 <#2> AphrontTagView::render() called at [<phorge>/src/view/AphrontView.php:222]
  #10 <#2> AphrontView::producePhutilSafeHTML() called at [<phorge>/src/infrastructure/markup/render.php:115]
  #11 <#2> phutil_escape_html(PHUITwoColumnView) called at [<phorge>/src/infrastructure/markup/render.php:171]
  #12 <#2> phutil_implode_html(string, array) called at [<phorge>/src/view/page/PhabricatorBarePageView.php:58]
  #13 <#2> PhabricatorBarePageView::willRenderPage() called at [<phorge>/src/view/page/PhabricatorStandardPageView.php:217]
  #14 <#2> PhabricatorStandardPageView::willRenderPage() called at [<phorge>/src/view/page/AphrontPageView.php:46]
  #15 <#2> AphrontPageView::render() called at [<phorge>/src/view/page/PhabricatorStandardPageView.php:918]
  #16 <#2> PhabricatorStandardPageView::produceAphrontResponse() called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:722]
  #17 <#2> AphrontApplicationConfiguration::produceResponse(AphrontRequest, PhabricatorStandardPageView) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:299]
  #18 phlog(InvalidArgumentException) called at [<phorge>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
  #19 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, InvalidArgumentException) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:751]
  #20 AphrontApplicationConfiguration::handleThrowable(InvalidArgumentException) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:337]
  #21 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:204]
  #22 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phorge>/webroot/index.php:35]

Deployed the debug code, posting some excerpts here for "action":"browse" when going to https://phabricator.wikimedia.org/diffusion/OSWB/branches/main/.gitignore;5a588bf0ee10546ddb9d0872d1be1bf48b3f3c07 , last item shows that shortName is integer:

'DEBUG-02 path: .gitignore' at [/src/applications/diffusion/request/DiffusionRequest.php:455]
'DEBUG-02 path gettype: string' at [/src/applications/diffusion/request/DiffusionRequest.php:456]
'DEBUG-02 branch: main' at [/src/applications/diffusion/request/DiffusionRequest.php:457]
'DEBUG-02 branch gettype: string' at [/src/applications/diffusion/request/DiffusionRequest.php:458]
'DEBUG-03 params array: {"action":"browse","path":".gitignore","branch":"main","commit":"5a588bf0ee10546ddb9d0872d1be1bf48b3f3c07","lint":null}' at [/src/applications/diffusion/request/DiffusionRequest.php:470]

'DEBUG-01 branch shortName: main' at [/src/applications/diffusion/view/DiffusionBranchListView.php:78]
'DEBUG-01 branch shortName gettype: string' at [/src/applications/diffusion/view/DiffusionBranchListView.php:79]
'DEBUG-02 path: .gitignore' at [/src/applications/diffusion/request/DiffusionRequest.php:455]
'DEBUG-02 path gettype: string' at [/src/applications/diffusion/request/DiffusionRequest.php:456]
'DEBUG-02 branch: main' at [/src/applications/diffusion/request/DiffusionRequest.php:457]
'DEBUG-02 branch gettype: string' at [/src/applications/diffusion/request/DiffusionRequest.php:458]
'DEBUG-03 params array: {"action":"browse","branch":"main","path":".gitignore","commit":"5a588bf0ee10546ddb9d0872d1be1bf48b3f3c07","lint":null}' at [/src/applications/diffusion/request/DiffusionRequest.php:470]

'DEBUG-01 branch shortName: 820664' at [/src/applications/diffusion/view/DiffusionBranchListView.php:78]
'DEBUG-01 branch shortName gettype: integer' at [/src/applications/diffusion/view/DiffusionBranchListView.php:79]
'DEBUG-02 path: .gitignore' at [/src/applications/diffusion/request/DiffusionRequest.php:455]
'DEBUG-02 path gettype: string' at [/src/applications/diffusion/request/DiffusionRequest.php:456]
'DEBUG-02 branch: main' at [/src/applications/diffusion/request/DiffusionRequest.php:457]
'DEBUG-02 branch gettype: string' at [/src/applications/diffusion/request/DiffusionRequest.php:458]
'DEBUG-03 params array: {"action":"browse","branch":820664,"path":".gitignore","commit":"5a588bf0ee10546ddb9d0872d1be1bf48b3f3c07","lint":null}' at [/src/applications/diffusion/request/DiffusionRequest.php:470]

https://phabricator.wikimedia.org/diffusion/OSWB/repository/820664/ exists.

mysql:phstats@m3-slave.eqiad.wmnet [phabricator_repository]> SELECT id, repositoryPHID, refType, refNameRaw FROM repository_refcursor WHERE repositoryPHID = "PHID-REPO-e3rocpasjrkyxpisqft7" AND refNameRaw = "820664";
+---------+--------------------------------+---------+------------+
| id      | repositoryPHID                 | refType | refNameRaw |
+---------+--------------------------------+---------+------------+
| 2462691 | PHID-REPO-e3rocpasjrkyxpisqft7 | branch  | 820664     |
+---------+--------------------------------+---------+------------+
1 row in set (0.003 sec)

Code in https://phabricator.wikimedia.org/source/phabricator/browse/wmf%252Fstable/src/applications/diffusion/view/DiffusionBranchListView.php does assert_instances_of($branches, 'DiffusionRepositoryRef');. We might end up in https://we.phorge.it/source/phorge/browse/master/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php for setShortName().

The culprit is $map[$branch] = $branch_head; in https://we.phorge.it/source/phorge/browse/master/src/applications/diffusion/data/DiffusionGitBranch.php$105. Before $branch was a string, afterwards it is an integer.

I can reproduce this locally with upstream git master via F58959277.

Aklapper changed the task status from Open to Stalled.Apr 2 2025, 11:54 AM
Aklapper claimed this task.
Aklapper moved this task from Reported Upstream to Patch proposed upstream on the Upstream board.

This issue should now be fixed on phabricator.wikimedia.org after today's software deployment in T404134.