Mercurial "Undefined offset: 1"

Reproduction Instructions
Complete steps which allow someone else who does not have access to your environment to reproduce the bug.

  1. Install mercurial 4.8.2 (I think this is most likely the root cause as it looks like a parsing error)
  2. Observe or upload a remote mercurial repository
  3. See “Undefined offset: 1” error on diffusion repo main page
  4. See this stack trace:
[Tue Nov 17 05:17:09.461992 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953] [2020-11-17 05:17:09] EXCEPTION: (RuntimeException) Undefined offset: 1 at [<arcanist>/src/error/PhutilErrorHandler.php:258]
[Tue Nov 17 05:17:09.462498 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953] arcanist(head=stable, ref.stable=ac54d61d7af2), phabricator(head=stable, ref.stable=86ad69863930)
[Tue Nov 17 05:17:09.462509 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php:155]
[Tue Nov 17 05:17:09.462513 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #1 <#2> DiffusionHistoryQueryConduitAPIMethod::getMercurialResult(ConduitAPIRequest) called at [/src/applications/diffusion/conduit/DiffusionQueryConduitAPIMethod.php:158]
[Tue Nov 17 05:17:09.462517 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #2 <#2> DiffusionQueryConduitAPIMethod::getResult(ConduitAPIRequest) called at [/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php:35]
[Tue Nov 17 05:17:09.462521 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #3 <#2> DiffusionHistoryQueryConduitAPIMethod::getResult(ConduitAPIRequest) called at [/src/applications/diffusion/conduit/DiffusionQueryConduitAPIMethod.php:110]
[Tue Nov 17 05:17:09.462523 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #4 <#2> DiffusionQueryConduitAPIMethod::execute(ConduitAPIRequest) called at [/src/applications/conduit/method/ConduitAPIMethod.php:131]
[Tue Nov 17 05:17:09.462526 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #5 <#2> ConduitAPIMethod::executeMethod(ConduitAPIRequest) called at [/src/applications/conduit/call/ConduitCall.php:131]
[Tue Nov 17 05:17:09.462529 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #6 <#2> ConduitCall::executeMethod() called at [/src/applications/conduit/call/ConduitCall.php:81]
[Tue Nov 17 05:17:09.462531 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #7 <#2> ConduitCall::execute() called at [/src/applications/repository/storage/PhabricatorRepository.php:2274]
[Tue Nov 17 05:17:09.462534 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #8 <#2> PhabricatorRepository::newConduitFuture(PhabricatorUser, string, array, boolean) called at [/src/applications/diffusion/query/DiffusionQuery.php:80]
[Tue Nov 17 05:17:09.462538 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #9 <#2> DiffusionQuery::callConduitWithDiffusionRequest(PhabricatorUser, DiffusionMercurialRequest, string, array, boolean) called at [/src/applications/diffusion/controller/DiffusionController.php:257]
[Tue Nov 17 05:17:09.462542 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #10 <#2> DiffusionController::callConduitMethod(string, array) called at [/src/applications/diffusion/controller/DiffusionRepositoryController.php:200]
[Tue Nov 17 05:17:09.462545 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #11 <#2> DiffusionRepositoryController::buildNormalContent(DiffusionMercurialRequest) called at [/src/applications/diffusion/controller/DiffusionRepositoryController.php:102]
[Tue Nov 17 05:17:09.462547 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #12 <#2> DiffusionRepositoryController::handleRequest(AphrontRequest) called at [/src/aphront/configuration/AphrontApplicationConfiguration.php:288]
[Tue Nov 17 05:17:09.462550 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #13 phlog(RuntimeException) called at [<phabricator>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
[Tue Nov 17 05:17:09.462553 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #14 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, RuntimeException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:752]
[Tue Nov 17 05:17:09.462556 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #15 AphrontApplicationConfiguration::handleThrowable(RuntimeException) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:300]
[Tue Nov 17 05:17:09.462558 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #16 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:208]
[Tue Nov 17 05:17:09.462561 2020] [php7:notice] [pid 23363] [client 10.244.2.1:34953]   #17 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:35]

Phabricator/Arcanist Version

Phabricator Version Information

|Library|Version|Date|Branchpoint|
|phabricator|86ad69863930|Mon, Oct 19|b2e96df3a3be|
|arcanist|ac54d61d7af2|Mon, Oct 19|4b3baca999a4|

Output from Config > Version Information or arc version.
arcanist ac54d61d7af20f5d65ba889974f23a86bfb6cd57 (19 Oct 2020)

mercurial version
Mercurial Distributed SCM (version 4.8.2)

I can confirm that downgrading to mercurial 3.1.2 resolves the issue.