{"record":{"id":"e4ff5ff9f3f841bc","repo":"phacility/phabricator","slug":"failed-to-load-import-with-phid-s","errorCode":null,"errorMessage":"Failed to load import with PHID \"%s\".","messagePattern":"Failed to load import with PHID \"(.+?)\"\\.","errorType":"exception","errorClass":"PhabricatorWorkerPermanentFailureException","httpStatus":null,"severity":"error","filePath":"src/applications/calendar/worker/PhabricatorCalendarImportReloadWorker.php","lineNumber":45,"sourceCode":"      array(\n        'via' => idx($data, 'via', self::VIA_TRIGGER),\n      ));\n\n    $import_engine->importEventsFromSource($author, $import, false);\n  }\n\n  private function loadImport() {\n    $viewer = PhabricatorUser::getOmnipotentUser();\n\n    $data = $this->getTaskData();\n    $import_phid = idx($data, 'importPHID');\n\n    $import = id(new PhabricatorCalendarImportQuery())\n      ->setViewer($viewer)\n      ->withPHIDs(array($import_phid))\n      ->executeOne();\n    if (!$import) {\n      throw new PhabricatorWorkerPermanentFailureException(\n        pht(\n          'Failed to load import with PHID \"%s\".',\n          $import_phid));\n    }\n\n    return $import;\n  }\n\n}\n","sourceCodeStart":27,"sourceCodeEnd":55,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/calendar/worker/PhabricatorCalendarImportReloadWorker.php#L27-L55","documentation":"PhabricatorCalendarImportReloadWorker looks up the calendar import by the PHID stored in the task data; when the lookup fails it throws PhabricatorWorkerPermanentFailureException, which retires the task permanently instead of retrying. This is the correct outcome for a deleted import — retrying can never succeed.","triggerScenarios":"The import was deleted by the user between the time the task was queued and when a worker picked it up; Task data was written with a stale, typo'd, or fabricated importPHID; A task was requeued from an old dump after the DB row was purged","commonSituations":"Users deleting an ICS feed import while its refresh worker is still in the queue; bulk imports cancelled mid-flight; manual task-data manipulation during debugging.","solutions":["Treat it as expected noise: log and ignore PhabricatorWorkerPermanentFailureException for deleted imports","Before queueing the worker, verify the import still exists (query by PHID) to avoid queuing work for rows deleted in the same request","If imports are vanishing unexpectedly, audit who/what deletes them (daemon log, herald rules) rather than retrying the task"],"exampleFix":"// before\n$this->yieldToClusterQueueForImport($import);\n\n// after: confirm the row exists before queuing the reload task\n$import = id(new PhabricatorCalendarImportQuery())\n  ->setViewer(PhabricatorUser::getOmnipotentUser())\n  ->withPHIDs(array($phid))\n  ->executeOne();\nif ($import) {\n  PhabricatorWorker::scheduleTask(\n    'PhabricatorCalendarImportReloadWorker',\n    array('importPHID' => $import->getPHID()));\n}","handlingStrategy":"validation","validationCode":"$import = id(new PhabricatorCalendarImportQuery())\n  ->setViewer(PhabricatorUser::getOmnipotentUser())\n  ->withPHIDs(array($import_phid))\n  ->executeOne();\nif (!$import) {\n  // Import deleted before scheduling: skip queuing the task entirely.\n  return;\n}\nPhabricatorWorker::scheduleTask(\n  'PhabricatorCalendarImportReloadWorker',\n  array('importPHID' => $import->getPHID()));","typeGuard":null,"tryCatchPattern":"// Permanent failures are terminal by design: do not retry them.\ntry {\n  $worker->executeTask();\n} catch (PhabricatorWorkerPermanentFailureException $ex) {\n  phlog('Import reload skipped (import no longer exists): '.$ex->getMessage());\n}","preventionTips":["Queue worker tasks in the same transaction that creates/verifies the row they reference","Treat PhabricatorWorkerPermanentFailureException as an expected terminal state, never a retry candidate","When users delete imports, log the deletion so later permanent failures are explainable"],"tags":["phabricator","calendar","worker-queue","phid","permanent-failure"],"backgroundTag":"missing-database-record","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}