{"record":{"id":"6e4661a8fd7543e1","repo":"phacility/phabricator","slug":"use-as-format-to-select-a-target-encoding-form","errorCode":null,"errorMessage":"Use --as <format> to select a target encoding format. Available formats are: %s.","messagePattern":"Use --as <format> to select a target encoding format\\. Available formats are: (.+?)\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/files/management/PhabricatorFilesManagementEncodeWorkflow.php","lineNumber":46,"sourceCode":"    $this\n      ->setName('encode')\n      ->setSynopsis(\n        pht('Change the storage encoding of files.'))\n      ->setArguments($arguments);\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $iterator = $this->buildIterator($args);\n\n    $force = (bool)$args->getArg('force');\n\n    $format_list = PhabricatorFileStorageFormat::getAllFormats();\n    $format_list = array_keys($format_list);\n    $format_list = implode(', ', $format_list);\n\n    $format_key = $args->getArg('as');\n    if (!strlen($format_key)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Use --as <format> to select a target encoding format. Available '.\n          'formats are: %s.',\n          $format_list));\n    }\n\n    $format = PhabricatorFileStorageFormat::getFormat($format_key);\n    if (!$format) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Storage format \"%s\" is not valid. Available formats are: %s.',\n          $format_key,\n          $format_list));\n    }\n\n    $key_name = $args->getArg('key');\n    if (strlen($key_name)) {\n      $format->selectMasterKey($key_name);","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/management/PhabricatorFilesManagementEncodeWorkflow.php#L28-L64","documentation":"The `./bin/files encode` workflow re-encodes stored files into a target format selected by --as <format-key>; the argument is required and this error is thrown when it is absent or empty. The message lists every registered format key (from PhabricatorFileStorageFormat::getAllFormats()) so the valid choices are visible.","triggerScenarios":"Running `./bin/files encode F123` with no --as; passing --as \"\" (empty string).","commonSituations":"Assuming the workflow re-encrypts with the existing format or that a default exists; truncated command lines in documentation or scripts.","solutions":["Add --as with a key from the listed formats: `./bin/files encode --as aes-256-cbc F123`","For encrypted targets without a default key, also pass --key <name>"],"exampleFix":"# before\n./bin/files encode F123\n\n# after\n./bin/files encode --as aes-256-cbc --key prod-2024 F123","handlingStrategy":"validation","validationCode":"# Script-side guard before running encode:\n[ -n \"$FORMAT_KEY\" ] || { echo 'usage: encode.sh <format-key> <file>' >&2; exit 2; }\n./bin/files encode --as \"$FORMAT_KEY\" \"$FILE_MONO\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair encode invocations with an explicit --as from the documented format list","For encrypted targets, decide up front whether --key is needed based on the keyring default"],"tags":["cli","usage","storage-format","files","phabricator"],"backgroundTag":"missing-required-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}