{"record":{"id":"e23517b2146c8901","repo":"phacility/phabricator","slug":"unable-to-load-file-s-for-import","errorCode":null,"errorMessage":"Unable to load file (\"%s\") for import.","messagePattern":"Unable to load file \\(\"(.+?)\"\\) for import\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php","lineNumber":79,"sourceCode":"    } else {\n      return pht('ICS File');\n    }\n  }\n\n  public function importEventsFromSource(\n    PhabricatorUser $viewer,\n    PhabricatorCalendarImport $import,\n    $should_queue) {\n\n    $phid_key = PhabricatorCalendarImportICSFileTransaction::PARAMKEY_FILE;\n    $file_phid = $import->getParameter($phid_key);\n\n    $file = id(new PhabricatorFileQuery())\n      ->setViewer($viewer)\n      ->withPHIDs(array($file_phid))\n      ->executeOne();\n    if (!$file) {\n      throw new Exception(\n        pht(\n          'Unable to load file (\"%s\") for import.',\n          $file_phid));\n    }\n\n    $data = $file->loadFileData();\n\n    if ($should_queue && $this->shouldQueueDataImport($data)) {\n      return $this->queueDataImport($import, $data);\n    }\n\n    return $this->importICSData($viewer, $import, $data);\n  }\n\n  public function canDisable(\n    PhabricatorUser $viewer,\n    PhabricatorCalendarImport $import) {\n    return false;","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php#L61-L97","documentation":"Thrown by the Calendar ICS file import engine when it cannot load the PhabricatorFile identified by the import's stored file PHID (parameter of PhabricatorCalendarImportICSFileTransaction). The file is queried with the acting viewer, so the load fails if the PHID is missing/null, the file was deleted or expired, or the viewer cannot see it under file policies.","triggerScenarios":"Import executed after the ICS file was deleted in the Files application or garbage-collected by TTL; import created without the file parameter; running the import as a user/daemon whose view policy excludes the file.","commonSituations":"Files application TTL or periodic garbage collection removes the ICS; imports created by one user then executed by daemons under a different viewer; restoring imports from a backup with stale PHIDs.","solutions":["Open the Files application and confirm a file with that PHID still exists (search by PHID) and is visible to the importing user.","If the file is gone, delete and re-create the Calendar import with a fresh ICS file upload.","If the file exists but is policy-restricted, loosen its view policy or run/re-create the import as an administrator.","Check 'phd status' - queued imports execute via daemons; ensure they run so imports use the intended viewer."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before running the import, verify the file is loadable by this viewer:\n$phid = $import->getParameter(\n  PhabricatorCalendarImportICSFileTransaction::PARAMKEY_FILE);\n$file = id(new PhabricatorFileQuery())\n  ->setViewer($viewer)\n  ->withPHIDs(array($phid))\n  ->executeOne();\nif (!$file) {\n  // mark the import failed with a clear message; do not call the engine\n  $import->newLogMessage(PhabricatorCalendarImportOrphanLogType::LOGTYPE);\n  return;\n}","typeGuard":"function importFileIsLoadable($viewer, $import) {\n  $phid = $import->getParameter(\n    PhabricatorCalendarImportICSFileTransaction::PARAMKEY_FILE);\n  if (!phutil_nonempty_string($phid)) {\n    return false;\n  }\n  return (bool) id(new PhabricatorFileQuery())\n    ->setViewer($viewer)\n    ->withPHIDs(array($phid))\n    ->executeOne();\n}","tryCatchPattern":"try {\n  $engine->importFromFile($viewer, $import, $should_queue);\n} catch (Exception $ex) {\n  // record the failure on the import object; do not blindly retry\n  $import->setStatus(PhabricatorCalendarImport::STATUS_FAILED)\n    ->save();\n  phlog($ex);\n}","preventionTips":["Run PhabricatorFileQuery with the same viewer that will execute the import.","Keep ICS files referenced by imports exempt from TTL/expiry deletion.","Verify stored PHIDs after restoring from backups."],"tags":["phabricator","calendar","ics-import","file-not-found","policy"],"backgroundTag":"file-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}