phacility/phabricator · error · Exception

Unable to load file ("%s") for import.

Error message

Unable to load file ("%s") for import.

What it means

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.

Source

Thrown at src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php:79

    } else {
      return pht('ICS File');
    }
  }

  public function importEventsFromSource(
    PhabricatorUser $viewer,
    PhabricatorCalendarImport $import,
    $should_queue) {

    $phid_key = PhabricatorCalendarImportICSFileTransaction::PARAMKEY_FILE;
    $file_phid = $import->getParameter($phid_key);

    $file = id(new PhabricatorFileQuery())
      ->setViewer($viewer)
      ->withPHIDs(array($file_phid))
      ->executeOne();
    if (!$file) {
      throw new Exception(
        pht(
          'Unable to load file ("%s") for import.',
          $file_phid));
    }

    $data = $file->loadFileData();

    if ($should_queue && $this->shouldQueueDataImport($data)) {
      return $this->queueDataImport($import, $data);
    }

    return $this->importICSData($viewer, $import, $data);
  }

  public function canDisable(
    PhabricatorUser $viewer,
    PhabricatorCalendarImport $import) {
    return false;

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Open the Files application and confirm a file with that PHID still exists (search by PHID) and is visible to the importing user.
  2. If the file is gone, delete and re-create the Calendar import with a fresh ICS file upload.
  3. If the file exists but is policy-restricted, loosen its view policy or run/re-create the import as an administrator.
  4. Check 'phd status' - queued imports execute via daemons; ensure they run so imports use the intended viewer.
Defensive patterns

Strategy: try-catch

Validate before calling

// Before running the import, verify the file is loadable by this viewer:
$phid = $import->getParameter(
  PhabricatorCalendarImportICSFileTransaction::PARAMKEY_FILE);
$file = id(new PhabricatorFileQuery())
  ->setViewer($viewer)
  ->withPHIDs(array($phid))
  ->executeOne();
if (!$file) {
  // mark the import failed with a clear message; do not call the engine
  $import->newLogMessage(PhabricatorCalendarImportOrphanLogType::LOGTYPE);
  return;
}

Type guard

function importFileIsLoadable($viewer, $import) {
  $phid = $import->getParameter(
    PhabricatorCalendarImportICSFileTransaction::PARAMKEY_FILE);
  if (!phutil_nonempty_string($phid)) {
    return false;
  }
  return (bool) id(new PhabricatorFileQuery())
    ->setViewer($viewer)
    ->withPHIDs(array($phid))
    ->executeOne();
}

Try / catch

try {
  $engine->importFromFile($viewer, $import, $should_queue);
} catch (Exception $ex) {
  // record the failure on the import object; do not blindly retry
  $import->setStatus(PhabricatorCalendarImport::STATUS_FAILED)
    ->save();
  phlog($ex);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/e23517b2146c8901. Report an issue: GitHub.