phacility/phabricator · warning · PhutilArgumentUsageException

Unable to load Calendar import with ID "%s".

Error message

Unable to load Calendar import with ID "%s".

What it means

Thrown by bin/calendar import-reload when one of the given IDs does not resolve to a Calendar import visible to the acting viewer (loaded via PhabricatorCalendarImportQuery). The whole command aborts before reloading anything, even if other IDs were valid.

Source

Thrown at src/applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php:40

  }

  public function execute(PhutilArgumentParser $args) {
    $viewer = $this->getViewer();

    $ids = $args->getArg('ids');
    if (!$ids) {
      throw new PhutilArgumentUsageException(
        pht('Specify at least one import ID to reload.'));
    }

    $imports = id(new PhabricatorCalendarImportQuery())
      ->setViewer($viewer)
      ->withIDs($ids)
      ->execute();
    $imports = mpull($imports, null, 'getID');
    foreach ($ids as $id) {
      if (empty($imports[$id])) {
        throw new PhutilArgumentUsageException(
          pht(
            'Unable to load Calendar import with ID "%s".',
            $id));
      }
    }

    $imports = array_select_keys($imports, $ids);

    foreach ($imports as $import) {
      echo tsprintf(
        "%s\n",
        pht(
          'Importing "%s"...',
          $import->getDisplayName()));

      $engine = $import->getEngine();

      $engine->importEventsFromSource($viewer, $import, false);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Verify each ID in Calendar -> Imports (the URI /calendar/import/ lists them; the ID is the number in /import/NN).
  2. Run the command as an administrator or the import owner if visibility policies block loading.
  3. Drop the offending ID and re-run with only the IDs that load.
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight the IDs with the same query the workflow uses:
$imports = id(new PhabricatorCalendarImportQuery())
  ->setViewer($this->getViewer())
  ->withIDs($ids)
  ->execute();
$loadable = mpull($imports, 'getID');
$missing = array_diff($ids, $loadable);
if ($missing) {
  fwrite(STDERR, 'Skipping unloadable import IDs: '.implode(', ', $missing)."\n");
}
$ids = $loadable; // proceed only with what actually loads

Try / catch

try {
  $workflow->execute($args);
} catch (PhutilArgumentUsageException $ex) {
  // usually a typo'd or policy-hidden ID; print and strip the bad ID
  fwrite(STDERR, $ex->getMessage()."\n");
  exit(1);
}

Prevention

When it happens

Trigger: 'bin/calendar import-reload 999999' (nonexistent ID); typo'd ID; import deleted; import not visible to the user running the command (policy filtering); passing an event ID instead of an import ID.

Common situations: Copy-pasting the event ID from a URL (/E123) instead of the import ID; imports owned by another user while running the CLI as a non-admin; stale IDs after imports were deleted.

Related errors


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