PhabricatorRepositoryIdentity::attachEffectiveUser() must be an instance of PhabricatorUser, null given


#1

Observed Behavior:
In /var/log/phd/daemon.log i’m observing following issue:

[17-Aug-2018 08:25:09 Europe/Prague] [2018-08-17 08:25:09] EXCEPTION: (PhutilProxyException) Error while executing Task ID 9586123. {>} (InvalidArgumentException) Argument 1 passed to PhabricatorRepositoryIdentity::attachEffectiveUser() must be an instance of PhabricatorUser, null given, called in /srv/phabricator/phabricator/src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php on line 143 and defined at [<phutil>/src/error/PhutilErrorHandler.php:200]
[17-Aug-2018 08:25:09 Europe/Prague] arcanist(head=stable, ref.master=4d6d3feb7fc1, ref.stable=830661f62833), phabricator(head=stable, ref.stable=58e8d3c13479), phutil(head=stable, ref.master=e9e79fd8d7f5, ref.stable=340445cf6947)
[17-Aug-2018 08:25:09 Europe/Prague]   #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<phabricator>/src/applications/repository/storage/PhabricatorRepositoryIdentity.php:19]
[17-Aug-2018 08:25:09 Europe/Prague]   #1 <#2> PhabricatorRepositoryIdentity::attachEffectiveUser(NULL) called at [<phabricator>/src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php:143]
[17-Aug-2018 08:25:09 Europe/Prague]   #2 <#2> PhabricatorRepositoryIdentityQuery::didFilterPage(array) called at [<phabricator>/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php:273]
[17-Aug-2018 08:25:09 Europe/Prague]   #3 <#2> PhabricatorPolicyAwareQuery::execute() called at [<phabricator>/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php:168]
[17-Aug-2018 08:25:09 Europe/Prague]   #4 <#2> PhabricatorPolicyAwareQuery::executeOne() called at [<phabricator>/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php:72]
[17-Aug-2018 08:25:09 Europe/Prague]   #5 <#2> PhabricatorRepositoryCommitMessageParserWorker::updateCommitData(DiffusionCommitRef) called at [<phabricator>/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php:42]
[17-Aug-2018 08:25:09 Europe/Prague]   #6 <#2> PhabricatorRepositoryCommitMessageParserWorker::parseCommit(PhabricatorRepository, PhabricatorRepositoryCommit) called at [<phabricator>/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php:51]
[17-Aug-2018 08:25:09 Europe/Prague]   #7 <#2> PhabricatorRepositoryCommitParserWorker::doWork() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:123]
[17-Aug-2018 08:25:09 Europe/Prague]   #8 <#2> PhabricatorWorker::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php:171]
[17-Aug-2018 08:25:09 Europe/Prague]   #9 <#2> PhabricatorWorkerActiveTask::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php:22]
[17-Aug-2018 08:25:09 Europe/Prague]   #10 PhabricatorTaskmasterDaemon::run() called at [<phutil>/src/daemon/PhutilDaemon.php:219]
[17-Aug-2018 08:25:09 Europe/Prague]   #11 PhutilDaemon::execute() called at [<phutil>/scripts/daemon/exec/exec_daemon.php:131]

it’s flooding my logs. I suspect that his has something to do with bin/destroy __username__

Expected Behavior:
Exception should be handled. I did hacky patch:

    foreach ($identities as $identity) {
      if ($identity->hasEffectiveUser()) {
        $user = idx($users, $identity->getCurrentEffectiveUserPHID());
        if ($user == null) {
           __ do some logging here __
        } else {
           $identity->attachEffectiveUser($user);
        }
      }
    }

Phabricator Version:

phabricator

b348fb1b550c382fed18eaeab67c7d9d90fa7a54 (Fri, Aug 10) (branched from a6951a0a5aa0510b702f32ea68c014e99e174b18 on origin)

arcanist

9dfa68d739ee05e806018821cd4d997307ae54f1 (Mon, Aug 6) (branched from d9a4293ae734756823b4a3ca202f185c57f3e834 on origin)

phutil

5a1a8323ee8073ccaf8d9ea8120309717d1d5db9 (Mon, Aug 6) (branched from dd136d1c371211d2830d94933b6c3cb0afce7c46 on origin)

diff

3.3 at /usr/bin/diff

git

2.11.0 at /usr/bin/git

hg

Not Available

pygmentize

2.0.1 at /usr/bin/pygmentize

svn

Not Available

Reproduction Steps:

Not sure, but bin/destroy of given user that has commits in GIT repo should produce the issue.


#2

I’m running into a similar problem for a given user, and I have no clue where the issue is (the user’s email used in the commits is tied to his account):

[2019-02-28 14:12:10] EXCEPTION: (InvalidArgumentException) Argument 1 passed to PhabricatorRepositoryIdentity::attachEffectiveUser() must be an instance of PhabricatorUser, null given, called in /srv/phabricator/phabricator/src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php on line 143 and defined at [<phutil>/src/error/PhutilErrorHandler.php:200]
arcanist(head=stable, ref.master=a60454810102, ref.stable=b4a302683b1a), phabricator(head=stable, ref.master=ee32c186dd82, ref.stable=e6331ca8efc1), phutil(head=stable, ref.master=20eff1c8d14f, ref.stable=813a26a2d097)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<phabricator>/src/applications/repository/storage/PhabricatorRepositoryIdentity.php:19]
  #1 PhabricatorRepositoryIdentity::attachEffectiveUser(NULL) called at [<phabricator>/src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php:143]
  #2 PhabricatorRepositoryIdentityQuery::didFilterPage(array) called at [<phabricator>/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php:273]
  #3 PhabricatorPolicyAwareQuery::execute() called at [<phabricator>/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php:168]
  #4 PhabricatorPolicyAwareQuery::executeOne() called at [<phabricator>/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php:72]
  #5 PhabricatorRepositoryCommitMessageParserWorker::updateCommitData(DiffusionCommitRef) called at [<phabricator>/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php:42]
  #6 PhabricatorRepositoryCommitMessageParserWorker::parseCommit(PhabricatorRepository, PhabricatorRepositoryCommit) called at [<phabricator>/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php:51]
  #7 PhabricatorRepositoryCommitParserWorker::doWork() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:124]
  #8 PhabricatorWorker::executeTask() called at [<phabricator>/src/applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php:325]
  #9 PhabricatorRepositoryManagementReparseWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:457]
  #10 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:349]
  #11 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/repository/manage_r
epositories.php:22]

edit: This issue was caused because a row in the repository_identity table (in the phabricator_repository database) had a stale currentEffectiveUserPHID which did not exist anymore.

The best guess to why this is so is that the user’s account has once been completely purged using the CLI and then later recreated.

The fix involved setting currentEffectiveUserPHID to the correct value.


#3

Thanks, see https://secure.phabricator.com/D20224.