{"record":{"id":"b2d6bdb0a0905bf2","repo":"phacility/phabricator","slug":"options-to-to-choose-a-specific-storage-forma","errorCode":null,"errorMessage":"Options \"--to\" (to choose a specific storage format) and \"--auto\" (to select a storage format automatically) are mutually exclusive.","messagePattern":"Options \"--to\" \\(to choose a specific storage format\\) and \"--auto\" \\(to select a storage format automatically\\) are mutually exclusive\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php","lineNumber":61,"sourceCode":"    $id = $args->getArg('id');\n    $is_all = $args->getArg('all');\n\n    if ($is_all && $id) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          '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])) {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php#L43-L79","documentation":"./bin/differential migrate-hunk lets you pick the target storage format either explicitly with --to <type> or automatically with --auto. Passing both is contradictory (auto-selection versus explicit choice), so the workflow throws this usage exception before validating the type value.","triggerScenarios":"Running './bin/differential migrate-hunk --all --to text --auto'; scripts templating '--to $FORMAT' while also hardcoding --auto; combining flags from two different documented invocations.","commonSituations":"Runbook evolution where --auto was added later to an existing command with --to; cron wrappers appending flags conditionally until both appear.","solutions":["Choose one: --to text|file for an explicit format, or --auto to let Phabricator pick","Parametrize the format flags in scripts so exactly one of --to/--auto is emitted","Follow with --dry-run to verify the selected behavior before the real run"],"exampleFix":"# before\nphabricator/ $ ./bin/differential migrate-hunk --all --to text --auto\nUsage Exception: Options \"--to\" ... and \"--auto\" ... are mutually exclusive.\n\n# after\nphabricator/ $ ./bin/differential migrate-hunk --all --auto","handlingStrategy":"validation","validationCode":"# Emit exactly one format flag\nif [ -n \"$TO_FORMAT\" ] && [ \"$AUTO\" = \"1\" ]; then\n  echo \"pick either --to or --auto, not both\" >&2; exit 64\nfi\nphabricator/bin/differential migrate-hunk --all ${TO_FORMAT:+--to \"$TO_FORMAT\"} ${AUTO:+--auto}","typeGuard":null,"tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // --to/--auto conflict: keep one flag, re-run.\n}","preventionTips":["Represent the format choice as one tri-state variable (auto|text|file) in wrappers","Prefer --auto in scheduled migrations; reserve --to for deliberate, tested migrations"],"tags":["phabricator","differential","cli","migrate-hunk","mutually-exclusive-flags","usage-error"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}