{"record":{"id":"bd78f3dd53ad223b","repo":"phacility/phabricator","slug":"storage-format-s-can-not-generate-keys","errorCode":null,"errorMessage":"Storage format \"%s\" can not generate keys.","messagePattern":"Storage format \"(.+?)\" can not generate keys\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/files/management/PhabricatorFilesManagementGenerateKeyWorkflow.php","lineNumber":38,"sourceCode":"\n  public function execute(PhutilArgumentParser $args) {\n    $type = $args->getArg('type');\n    if (!strlen($type)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify the type of key to generate with --type.'));\n    }\n\n    $format = PhabricatorFileStorageFormat::getFormat($type);\n    if (!$format) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'No key type \"%s\" exists.',\n          $type));\n    }\n\n    if (!$format->canGenerateNewKeyMaterial()) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Storage format \"%s\" can not generate keys.',\n          $format->getStorageFormatName()));\n    }\n\n    $material = $format->generateNewKeyMaterial();\n\n    $structure = array(\n      'name' => 'generated-key-'.Filesystem::readRandomCharacters(12),\n      'type' => $type,\n      'material.base64' => $material,\n    );\n\n    $json = id(new PhutilJSON())->encodeFormatted($structure);\n\n    echo tsprintf(\n      \"%s: %s\\n\\n%B\\n\",\n      pht('Key Material'),","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/management/PhabricatorFilesManagementGenerateKeyWorkflow.php#L20-L56","documentation":"Capability guard in the generate-key workflow: the named storage format exists but canGenerateNewKeyMaterial() is false, i.e. that format does not support server-side key generation (for example, a plaintext or external-key format). A different type must be chosen to generate a key.","triggerScenarios":"Thrown at src/applications/files/management/PhabricatorFilesManagementGenerateKeyWorkflow.php:38 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a key-capable format type for --type","Generate the key material externally if the format requires client-provided keys"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","contentChangedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}