{"record":{"id":"5317ed40491dbf8c","repo":"phacility/phabricator","slug":"failed-to-parse-object-address-s-during-proce","errorCode":null,"errorMessage":"Failed to parse object address (\"%s\") during processing.","messagePattern":"Failed to parse object address \\(\"(.+?)\"\\) during processing\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/metamta/receiver/PhabricatorObjectMailReceiver.php","lineNumber":38,"sourceCode":"   * this pattern is some sort of object ID.\n   *\n   * @param   string          A string matched by @{method:getObjectPattern}\n   *                          fragment.\n   * @param   PhabricatorUser The viewing user.\n   * @return  void\n   */\n  abstract protected function loadObject($pattern, PhabricatorUser $viewer);\n\n\n  final protected function processReceivedMail(\n    PhabricatorMetaMTAReceivedMail $mail,\n    PhutilEmailAddress $target) {\n\n    $parts = $this->matchObjectAddress($target);\n    if (!$parts) {\n      // We should only make it here if we matched already in \"canAcceptMail()\",\n      // so this is a surprise.\n      throw new Exception(\n        pht(\n          'Failed to parse object address (\"%s\") during processing.',\n          (string)$target));\n    }\n\n    $pattern = $parts['pattern'];\n    $sender = $this->getSender();\n\n    try {\n      $object = $this->loadObject($pattern, $sender);\n    } catch (PhabricatorPolicyException $policy_exception) {\n      throw new PhabricatorMetaMTAReceivedMailProcessingException(\n        MetaMTAReceivedMailStatus::STATUS_POLICY_PROBLEM,\n        pht(\n          'This mail is addressed to an object (\"%s\") you do not have '.\n          'permission to see: %s',\n          $pattern,\n          $policy_exception->getMessage()));","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/metamta/receiver/PhabricatorObjectMailReceiver.php#L20-L56","documentation":"In PhabricatorObjectMailReceiver::processReceivedMail(), matchObjectAddress() failed to re-parse the target address that had already been accepted by canAcceptMail(). The source comment marks this 'a surprise': it indicates inconsistent matching logic (nearly always in a custom receiver subclass) rather than bad input, and throws a plain Exception.","triggerScenarios":"A custom PhabricatorObjectMailReceiver subclass whose canAcceptMail()/matchObjectAddress() use different patterns or normalization, so an address accepted by one is rejected by the other; address normalization (case, domain, plus-addressing) changing between the two calls.","commonSituations":"Developing custom reply handlers or overriding object-address matching in extensions; upstream changes to matching combined with local overrides that were not updated.","solutions":["Audit any local overrides of matchObjectAddress()/canAcceptMail() for divergent logic and make both use one shared matcher.","Reproduce with `bin/mail show-inbound --id N` to see the exact target address being parsed.","If no local customizations exist, report upstream including the target address from the exception."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  $received->processReceivedMail();\n} catch (Exception $ex) {\n  // log the target address and receiver class with the exception;\n  // this error signals a matching-logic inconsistency, not user error\n  phlog($ex);\n}","preventionTips":["In custom receivers, implement matching once and call it from both canAcceptMail() and processReceivedMail().","Add tests that feed the same address through canAcceptMail() and matchObjectAddress() and assert they agree.","After upgrading Phabricator, re-run your receiver tests before enabling mail."],"tags":["php","phabricator","mail","invariant","custom-receiver"],"backgroundTag":"invariant-violation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}