{"record":{"id":"85767e9834c97071","repo":"phacility/phabricator","slug":"no-hunk-exists-with-id-s","errorCode":null,"errorMessage":"No hunk exists with ID \"%s\".","messagePattern":"No hunk exists with ID \"(.+?)\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php","lineNumber":120,"sourceCode":"          throw $ex;\n        }\n\n        $this->logWarn(\n          pht('WARN'),\n          pht(\n            'Failed to migrate hunk %d: %s',\n            $hunk->getID(),\n            $ex->getMessage()));\n      }\n    }\n\n    return 0;\n  }\n\n  private function loadHunk($id) {\n    $hunk = id(new DifferentialHunk())->load($id);\n    if (!$hunk) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'No hunk exists with ID \"%s\".',\n          $id));\n    }\n\n    return $hunk;\n  }\n\n  private function migrateHunk(\n    DifferentialHunk $hunk,\n    $type,\n    $is_auto,\n    $is_dry_run) {\n\n    $old_type = $hunk->getDataType();\n\n    if ($is_auto) {\n      // By default, we're just going to keep hunks in the same storage","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php#L102-L138","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","solutions":["Confirm the ID is from the differential_hunk table (not diff or revision IDs): query SELECT id FROM differential_hunk WHERE id = <id>","List candidate hunk IDs first (e.g., SELECT id, diffID FROM differential_hunk LIMIT ...) and rerun with a verified ID","If the goal is bulk migration, use --all instead of --id and let the LiskMigrationIterator cover every hunk","If migrating environment copies, regenerate your ID list against the current database"],"exampleFix":"# before\nphabricator/ $ ./bin/differential migrate-hunk --id 999999 --auto\nUsage Exception: No hunk exists with ID \"999999\".\n\n# after\nmysql> SELECT id, diffID FROM differential_hunk WHERE diffID = 4242;\nphabricator/ $ ./bin/differential migrate-hunk --id <real-hunk-id> --auto","handlingStrategy":"validation","validationCode":"// Verify the hunk ID exists in this database before migrating\n$hunk = id(new DifferentialHunk())->load($id);\nif (!$hunk) {\n  // regenerate your ID list; do not invoke migrate-hunk --id\n}","typeGuard":"function isHunkIdListCurrent($pdo, array $ids) {\n  $in = implode(',', array_map('intval', $ids));\n  $rows = $pdo->query(\"SELECT id FROM differential_hunk WHERE id IN ({$in})\")->fetchAll();\n  return count($rows) === count($ids);\n}","tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // Hunk gone: re-query current hunk IDs (or switch to --all) and retry.\n}","preventionTips":["Always take hunk IDs from a fresh query against the same database you migrate","Do not confuse hunk IDs with diff or revision IDs","For bulk work prefer --all, which iterates every hunk without ID bookkeeping"],"tags":["phabricator","differential","cli","migrate-hunk","hunk","not-found","id-lookup"],"backgroundTag":"entity-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}