phacility/phabricator · warning · PhutilArgumentUsageException

No hunk exists with ID "%s".

Error message

No hunk exists with ID "%s".

What it means

When migrate-hunk is run with --id, it loads the hunk through loadHunk() (id(new DifferentialHunk())->load($id)) and throws this usage exception if no hunk row has that primary key. The lookup is by raw ID across all hunks, so a miss means the ID genuinely does not exist (or the row was deleted between listing and running).

Source

Thrown at src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php:120

          throw $ex;
        }

        $this->logWarn(
          pht('WARN'),
          pht(
            'Failed to migrate hunk %d: %s',
            $hunk->getID(),
            $ex->getMessage()));
      }
    }

    return 0;
  }

  private function loadHunk($id) {
    $hunk = id(new DifferentialHunk())->load($id);
    if (!$hunk) {
      throw new PhutilArgumentUsageException(
        pht(
          'No hunk exists with ID "%s".',
          $id));
    }

    return $hunk;
  }

  private function migrateHunk(
    DifferentialHunk $hunk,
    $type,
    $is_auto,
    $is_dry_run) {

    $old_type = $hunk->getDataType();

    if ($is_auto) {
      // By default, we're just going to keep hunks in the same storage

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Confirm the ID is from the differential_hunk table (not diff or revision IDs): query SELECT id FROM differential_hunk WHERE id = <id>
  2. List candidate hunk IDs first (e.g., SELECT id, diffID FROM differential_hunk LIMIT ...) and rerun with a verified ID
  3. If the goal is bulk migration, use --all instead of --id and let the LiskMigrationIterator cover every hunk
  4. If migrating environment copies, regenerate your ID list against the current database

Example fix

# before
phabricator/ $ ./bin/differential migrate-hunk --id 999999 --auto
Usage Exception: No hunk exists with ID "999999".

# after
mysql> SELECT id, diffID FROM differential_hunk WHERE diffID = 4242;
phabricator/ $ ./bin/differential migrate-hunk --id <real-hunk-id> --auto
Defensive patterns

Strategy: validation

Validate before calling

// Verify the hunk ID exists in this database before migrating
$hunk = id(new DifferentialHunk())->load($id);
if (!$hunk) {
  // regenerate your ID list; do not invoke migrate-hunk --id
}

Type guard

function isHunkIdListCurrent($pdo, array $ids) {
  $in = implode(',', array_map('intval', $ids));
  $rows = $pdo->query("SELECT id FROM differential_hunk WHERE id IN ({$in})")->fetchAll();
  return count($rows) === count($ids);
}

Try / catch

try {
  $workflow->execute($args);
} catch (PhutilArgumentUsageException $ex) {
  // Hunk gone: re-query current hunk IDs (or switch to --all) and retry.
}

Prevention

When it happens

Trigger: Passing an ID copied from an older database dump after hunks were purged with the diff; fat-fingered ID; scripts iterating IDs from a list generated against a different environment; passing a diff ID or revision ID instead of the hunk ID (hunks have their own separate ID sequence).

Common situations: Migrating hunks on a restored/trimmed copy of production; operators confusing hunk.hunkID with diff.id or revision.id; partial cleanup jobs having already migrated and deleted hunks.

Related errors


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