{"record":{"id":"ed1230a99d0ddd86","repo":"phacility/phabricator","slug":"this-storage-format-s-does-not-support-key-se","errorCode":null,"errorMessage":"This storage format (\"%s\") does not support key selection.","messagePattern":"This storage format \\(\"(.+?)\"\\) does not support key selection\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/files/format/PhabricatorFileStorageFormat.php","lineNumber":50,"sourceCode":"\n  public function canGenerateNewKeyMaterial() {\n    return false;\n  }\n\n  public function generateNewKeyMaterial() {\n    throw new PhutilMethodNotImplementedException();\n  }\n\n  public function canCycleMasterKey() {\n    return false;\n  }\n\n  public function cycleStorageProperties() {\n    throw new PhutilMethodNotImplementedException();\n  }\n\n  public function selectMasterKey($key_name) {\n    throw new Exception(\n      pht(\n        'This storage format (\"%s\") does not support key selection.',\n        $this->getStorageFormatName()));\n  }\n\n  final public function getStorageFormatKey() {\n    return $this->getPhobjectClassConstant('FORMATKEY');\n  }\n\n  final public static function getAllFormats() {\n    return id(new PhutilClassMapQuery())\n      ->setAncestorClass(__CLASS__)\n      ->setUniqueMethod('getStorageFormatKey')\n      ->execute();\n  }\n\n  final public static function getFormat($key) {\n    $formats = self::getAllFormats();","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/format/PhabricatorFileStorageFormat.php#L32-L68","documentation":"PhabricatorFileStorageFormat::selectMasterKey() is only implemented by key-capable formats (the AES-256 format); the base class throws this Exception for every other format such as 'raw' and 'test'. It means the caller asked a storage format to use a named encryption key when that format has no concept of keys. The correct response is to drop the key argument or target a format that supports keys.","triggerScenarios":"Running `./bin/files encode --as raw --key prod-2024 F123` (any --key with a format other than aes-256-cbc); programmatically calling selectMasterKey($name) on a PhabricatorFileRawStorageFormat or any custom format that does not override the method.","commonSituations":"Copy-pasting the --key flag from an encryption command into a re-encode to a plain format; wrapper scripts that always pass --key regardless of the --as value.","solutions":["Remove the --key argument when encoding to a keyless format: `./bin/files encode --as raw F123`","Use --as aes-256-cbc if key selection was actually intended","In code, only call selectMasterKey() on formats that implement it (instances of PhabricatorFileAES256StorageFormat)"],"exampleFix":"# before\n./bin/files encode --as raw --key prod-2024 F123\n\n# after\n./bin/files encode --as raw F123","handlingStrategy":"validation","validationCode":"$format = PhabricatorFileStorageFormat::requireFormat($format_key);\nif (strlen($key_name) && !($format instanceof PhabricatorFileAES256StorageFormat)) {\n  // \"{$format_key}\" has no keys; do not call selectMasterKey() with --key.\n}","typeGuard":"function formatSupportsKeySelection(PhabricatorFileStorageFormat $format) {\n  return ($format instanceof PhabricatorFileAES256StorageFormat);\n}","tryCatchPattern":null,"preventionTips":["Only pass --key together with --as aes-256-cbc","Treat unimplemented base-class methods as capability checks: verify the concrete format class before calling capability methods","In wrapper scripts, derive --key presence from the format rather than passing it unconditionally"],"tags":["cli","usage","storage-format","files","phabricator"],"backgroundTag":"unsupported-operation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}