{"record":{"id":"a5dc66d7e36a34f9","repo":"phacility/phabricator","slug":"use-to-to-choose-a-storage-format-or-auto","errorCode":null,"errorMessage":"Use \"--to\" to choose a storage format, or \"--auto\" to select a format automatically.","messagePattern":"Use \"--to\" to choose a storage format, or \"--auto\" to select a format automatically\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php","lineNumber":67,"sourceCode":"          'Options \"--all\" (to migrate all hunks) and \"--id\" (to migrate a '.\n          'specific hunk) are mutually exclusive.'));\n    } else if (!$is_all && !$id) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify a hunk to migrate with \"--id\", or migrate all hunks '.\n          'with \"--all\".'));\n    }\n\n    $is_auto = $args->getArg('auto');\n    $storage = $args->getArg('to');\n    if ($is_auto && $storage) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Options \"--to\" (to choose a specific storage format) and \"--auto\" '.\n          '(to select a storage format automatically) are mutually '.\n          'exclusive.'));\n    } else if (!$is_auto && !$storage) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Use \"--to\" to choose a storage format, or \"--auto\" to select a '.\n          'format automatically.'));\n    }\n\n    $types = array(\n      DifferentialHunk::DATATYPE_TEXT,\n      DifferentialHunk::DATATYPE_FILE,\n    );\n    $types = array_fuse($types);\n    if (strlen($storage)) {\n      if (!isset($types[$storage])) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'Storage type \"%s\" is unknown. Supported types are: %s.',\n            $storage,\n            implode(', ', array_keys($types))));\n      }","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php#L49-L85","documentation":"./bin/differential migrate-hunk requires a target format: either --to <type> (choose 'text' or 'file' explicitly) or --auto (let the tool select). With neither flag the workflow throws this usage exception, refusing to run a migration with an undefined destination format.","triggerScenarios":"Running './bin/differential migrate-hunk --all' with scope but no format; scripts where the FORMAT variable is empty so '--to $FORMAT' is dropped; assuming a default format exists.","commonSituations":"First migrations following the scope-only part of a runbook; bash set -u absent so empty variables silently disappear; operators testing scope flags alone.","solutions":["Add --auto for automatic selection ('./bin/differential migrate-hunk --all --auto') or --to text / --to file for an explicit format","Use --dry-run with the format choice to preview writes","In scripts, default the format flag to --auto when unset"],"exampleFix":"# before\nphabricator/ $ ./bin/differential migrate-hunk --all\nUsage Exception: Use \"--to\" to choose a storage format, or \"--auto\" ...\n\n# after\nphabricator/ $ ./bin/differential migrate-hunk --all --auto","handlingStrategy":"validation","validationCode":"# Default the format choice explicitly\nFORMAT_FLAG=\"${FORMAT_FLAG:---auto}\"   # or validate it is '--to text' / '--to file'\nphabricator/bin/differential migrate-hunk --all $FORMAT_FLAG","typeGuard":null,"tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // Missing format: append --auto (or --to text|file) and re-run.\n}","preventionTips":["Never run migrate-hunk with scope flags only; the tool intentionally has no default format","Use --dry-run --auto to see what a complete, valid invocation would do"],"tags":["phabricator","differential","cli","migrate-hunk","missing-option","usage-error"],"backgroundTag":"missing-required-option","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}