{"record":{"id":"7e9f9c19a283b777","repo":"phacility/phabricator","slug":"no-public-key-was-provided","errorCode":null,"errorMessage":"No public key was provided.","messagePattern":"No public key was provided\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/auth/sshkey/PhabricatorAuthSSHPublicKey.php","lineNumber":28,"sourceCode":"  private $comment;\n\n  private function __construct() {\n    // <internal>\n  }\n\n  public static function newFromStoredKey(PhabricatorAuthSSHKey $key) {\n    $public_key = new PhabricatorAuthSSHPublicKey();\n    $public_key->type = $key->getKeyType();\n    $public_key->body = $key->getKeyBody();\n    $public_key->comment = $key->getKeyComment();\n\n    return $public_key;\n  }\n\n  public static function newFromRawKey($entire_key) {\n    $entire_key = trim($entire_key);\n    if (!strlen($entire_key)) {\n      throw new Exception(pht('No public key was provided.'));\n    }\n\n    $parts = str_replace(\"\\n\", '', $entire_key);\n\n    // The third field (the comment) can have spaces in it, so split this\n    // into a maximum of three parts.\n    $parts = preg_split('/\\s+/', $parts, 3);\n\n    if (preg_match('/private\\s*key/i', $entire_key)) {\n      // Try to give the user a better error message if it looks like\n      // they uploaded a private key.\n      throw new Exception(pht('Provide a public key, not a private key!'));\n    }\n\n    switch (count($parts)) {\n      case 1:\n        throw new Exception(\n          pht('Provided public key is not properly formatted.'));","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/auth/sshkey/PhabricatorAuthSSHPublicKey.php#L10-L46","documentation":"PhabricatorAuthSSHPublicKey::newFromRawKey() trims the submitted key text and immediately throws if nothing remains. It is the entry point for parsing any uploaded SSH public key (type + base64 body + comment), so empty input cannot be parsed.","triggerScenarios":"Calling newFromRawKey('') or with whitespace-only input - e.g. an SSH key upload form submitted with an empty textarea, or upstream code passing a failed file read (empty string) instead of the key contents.","commonSituations":"Users clicking submit before pasting; client-side upload where reading the file failed silently and '' was posted; automation passing an unset variable.","solutions":["Paste the full public key line (e.g. 'ssh-ed25519 AAAA... comment') and resubmit","If this comes from a file upload, verify the file actually read non-empty contents before submission","Check for form/JS bugs that clear or never populate the key field"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before calling PhabricatorAuthSSHPublicKey::newFromRawKey():\n$raw = trim($submitted_key_text);\nif (!strlen($raw)) {\n  // Block the empty submission in the form layer with a field error,\n  // not a fatal after submission.\n  $form_field->setError(pht('Required')); \n}","typeGuard":null,"tryCatchPattern":"try {\n  $public_key = PhabricatorAuthSSHPublicKey::newFromRawKey($raw);\n} catch (Exception $ex) {\n  // Attach the message ('No public key was provided.') to the form field.\n  $e_key = pht('Required');\n  $errors[] = $ex->getMessage();\n}","preventionTips":["Make the SSH public key field required and non-empty at the form validation layer","When importing from a file, fail early if the read produced zero bytes"],"tags":["ssh","public-key","validation","phabricator","empty-input"],"backgroundTag":"ssh-public-key-invalid","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}