Getting exception "Array item with key '61459' must be an instance of DifferentialInlineComment"

I’m getting this error in the UI when trying to compare two versions of a diff:

Array item with key '61459' must be an instance of DifferentialInlineComment, instance of DifferentialTransactionComment given.

Reproduction Instructions

  • Go to a diff
  • Go to the History to see all versions
  • Try to compare 2 versions
  • You’ll get the aforementioned exception. My url looks like https://phabricator.mycompany.com/D1234?vs=29984&id=29997#toc

Phabricator/Arcanist Version

Phabricator Version Information
Library     Version         Date        Branchpoint
phabricator	c358cff7bd72	Fri, May 8	e7ebd5d9d1f8
arcanist	22363974e2e0	Fri, May 8	6937d389472d

Can you dig a stack trace out of your webserver error log? This is definitely related to recent changes but I can’t immediately reproduce it.

Never mind, I think I found a reproduction case. The missing step was:

Try to compare 2 versions [where at least one file that wasn’t changed, or more than 100 total files are changed between the versions]

Sure, here you go:

2020/05/08 23:20:04 [error] 5275#5275: *803934 FastCGI sent in stderr: "PHP message: [2020-05-08 23:20:04] EXCEPTION: (InvalidArgumentException) Array item with key '61459' must be an instance of DifferentialInlineComment, instance of DifferentialTransactionComment given. at [<arcanist>/src/utils/utils.php:637]
PHP message: arcanist(head=deploy, ref.master=ee66b15bd469, ref.deploy=22363974e2e0), phabricator(head=deploy, ref.master=64cc4fe91515, ref.deploy=c358cff7bd72)
PHP message:   #0 <#2> assert_instances_of(array, string) called at [<phabricator>/src/infrastructure/diff/engine/PhabricatorInlineCommentAdjustmentEngine.php:22]
PHP message:   #1 <#2> PhabricatorInlineCommentAdjustmentEngine::setInlines(array) called at [<phabricator>/src/applications/differential/controller/DifferentialRevisionViewController.php:242]
PHP message:   #2 <#2> DifferentialRevisionViewController::handleRequest(AphrontRequest) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:288]
PHP message:   #3 phlog(InvalidArgumentException) called at [<phabricator>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
PHP message:   #4 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, InvalidArgumentException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:752]
PHP message:   #5 AphrontApplicationConfiguration::handleThrowable(InvalidArgumentException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:300]
PHP message:   #6 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:211]
PHP message:   #7 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:35]" while reading response header from upstream, client: 52.89.140.30, server: phabricator.mycompany.com, request: "GE

The last line is chopped like that in the file.

Thanks! That’s what I thought it was, fix coming up in a moment.

I believe this is fixed by https://secure.phabricator.com/D21239, which is now in master and stable. Let me know if you’re still seeing issues. Thanks for the report!

Yes, still seeing the exception:

2020/05/08 23:59:24 [error] 5274#5274: *804347 FastCGI sent in stderr: "PHP message: [2020-05-08 23:59:24] EXCEPTION: (InvalidArgumentException) Array item with key '61459' must be an instance of DifferentialIn
lineComment, instance of DifferentialTransactionComment given. at [<arcanist>/src/utils/utils.php:637]
PHP message: arcanist(head=deploy, ref.master=ee66b15bd469, ref.deploy=22363974e2e0), phabricator(head=deploy, ref.master=64cc4fe91515, ref.deploy=ebf254dac351)
PHP message:   #0 <#2> assert_instances_of(array, string) called at [<phabricator>/src/infrastructure/diff/engine/PhabricatorInlineCommentAdjustmentEngine.php:22]
PHP message:   #1 <#2> PhabricatorInlineCommentAdjustmentEngine::setInlines(array) called at [<phabricator>/src/applications/differential/controller/DifferentialRevisionViewController.php:242]
PHP message:   #2 <#2> DifferentialRevisionViewController::handleRequest(AphrontRequest) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:288]
PHP message:   #3 phlog(InvalidArgumentException) called at [<phabricator>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
PHP message:   #4 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, InvalidArgumentException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.p
hp:752]
PHP message:   #5 AphrontApplicationConfiguration::handleThrowable(InvalidArgumentException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:300]
PHP message:   #6 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phabricator>/src/aphront/configuration/AphrontApplicationC
onfiguration.php:211]
PHP message:   #7 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:35]" while reading response header from upstream, client: 52.89.140.30, server: X.com, request: "GE

I just pulled from stable and got a new commit. Should I restart something on the server?

This is what I see in the UI now:

|phabricator|ebf254dac351|Fri, May 8|e7ebd5d9d1f8|
|arcanist   |22363974e2e0|Fri, May 8|6937d389472d|

Yes, you usually have to restart the server for changes to take effect. See:

https://secure.phabricator.com/book/phabricator/article/restarting/

(The “Versions” panel may report a newer version than what’s actually cached in the Opcache if you haven’t restarted after upgrading.)

Restarted with sudo service nginx restart

And I get:

2020/05/09 00:10:22 [error] 26354#26354: *2 FastCGI sent in stderr: "PHP message: [2020-05-09 00:10:22] EXCEPTION: (InvalidArgumentException) Array item with key '61459' must be an instance of DifferentialInlineComment, instance of DifferentialTransactionComment given. at [<arcanist>/src/utils/utils.php:637]
PHP message: arcanist(head=deploy, ref.master=ee66b15bd469, ref.deploy=22363974e2e0), phabricator(head=deploy, ref.master=64cc4fe91515, ref.deploy=ebf254dac351)
PHP message:   #0 <#2> assert_instances_of(array, string) called at [<phabricator>/src/infrastructure/diff/engine/PhabricatorInlineCommentAdjustmentEngine.php:22]
PHP message:   #1 <#2> PhabricatorInlineCommentAdjustmentEngine::setInlines(array) called at [<phabricator>/src/applications/differential/controller/DifferentialRevisionViewController.php:242]
PHP message:   #2 <#2> DifferentialRevisionViewController::handleRequest(AphrontRequest) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:288]
PHP message:   #3 phlog(InvalidArgumentException) called at [<phabricator>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
PHP message:   #4 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, InvalidArgumentException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:752]
PHP message:   #5 AphrontApplicationConfiguration::handleThrowable(InvalidArgumentException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:300]
PHP message:   #6 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:211]
PHP message:   #7 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:35]" while reading response header from upstream, client: 52.89.140.30, server: phabricator.X.com, request: "GET /

If you’re using nginx + php_fpm, you must restart both processes (see the “Restarting” article for details).

You’re definitely hitting a cached version of DifferentialRevisionViewController.php because the trace says:

PHP message:   #1 <#2> PhabricatorInlineCommentAdjustmentEngine::setInlines(array) called at [<phabricator>/src/applications/differential/controller/DifferentialRevisionViewController.php:242]

…but line 242 no longer has a call to setInlines(...) (it’s now on line 244):

$ cat -n src/applications/differential/controller/DifferentialRevisionViewController.php | head -n 245 | tail -n 6
   240	        ->setViewer($viewer)
   241	        ->setRevision($revision)
   242	        ->setOldChangesets($old)
   243	        ->setNewChangesets($new)
   244	        ->setInlines($inlines)
   245	        ->execute();

Sorry, I missed that part, after doing this:

sudo service php7.2-fpm reload

The issue got resolved.

Thanks!

Great, thanks again!