{"record":{"id":"2cc820f2811b97b4","repo":"phacility/phabricator","slug":"credential-has-invalid-type-s-2cc820","errorCode":null,"errorMessage":"Credential has invalid type \"%s\"!","messagePattern":"Credential has invalid type \"(.+?)\"!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/passphrase/controller/PassphraseCredentialPublicController.php","lineNumber":25,"sourceCode":"    $viewer = $request->getViewer();\n    $id = $request->getURIData('id');\n\n    $credential = id(new PassphraseCredentialQuery())\n      ->setViewer($viewer)\n      ->withIDs(array($id))\n      ->requireCapabilities(\n        array(\n          PhabricatorPolicyCapability::CAN_VIEW,\n        ))\n      ->executeOne();\n    if (!$credential) {\n      return new Aphront404Response();\n    }\n\n    $type = PassphraseCredentialType::getTypeByConstant(\n      $credential->getCredentialType());\n    if (!$type) {\n      throw new Exception(pht('Credential has invalid type \"%s\"!', $type));\n    }\n\n    if (!$type->hasPublicKey()) {\n      throw new Exception(pht('Credential has no public key!'));\n    }\n\n    $view_uri = '/'.$credential->getMonogram();\n\n    $public_key = $type->getPublicKey($viewer, $credential);\n\n    $body = id(new PHUIFormLayoutView())\n      ->appendChild(\n        id(new AphrontFormTextAreaControl())\n          ->setLabel(pht('Public Key'))\n          ->setReadOnly(true)\n          ->setValue($public_key));\n\n    return $this->newDialog()","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/passphrase/controller/PassphraseCredentialPublicController.php#L7-L43","documentation":"Thrown by PassphraseCredentialPublicController when the public-key view (/K<id>/public) loads a credential whose stored type constant does not resolve to an installed PassphraseCredentialType implementation. The page needs the type object to check hasPublicKey() and to render the key, so an orphaned type constant fails before rendering. As with the other controllers, the message prints the null lookup result rather than the stored constant.","triggerScenarios":"Visiting /K<id>/public for a credential whose credentialType constant belongs to a removed or disabled extension.","commonSituations":"Links to the public-key page surviving in templates or bookmarks after the providing extension was disabled; cross-environment database restores.","solutions":["Read $credential->getCredentialType() and diff against constants from PassphraseCredentialType::getAllTypes().","Restore the extension that owns the constant.","Delete the orphaned credential and recreate it with a supported type."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$all = PassphraseCredentialType::getAllTypes();\nif (empty($all[$credential->getCredentialType()])) {\n  // skip the /public link entirely\n}","typeGuard":"function can_view_public_key($credential) {\n  $type = PassphraseCredentialType::getTypeByConstant(\n    $credential->getCredentialType());\n  return $type !== null && $type->hasPublicKey();\n}","tryCatchPattern":"try {\n  $type = PassphraseCredentialType::getTypeByConstant(\n    $credential->getCredentialType());\n} catch (Exception $ex) {\n  // suppress the public-key action for this credential\n}","preventionTips":["Guard the /public link on both type resolution and hasPublicKey().","Remove extension-provided credential types only after deleting their credentials.","Verify extension availability after restoring databases across installs."],"tags":["phabricator","passphrase","credentials","public-key","extension"],"backgroundTag":"unknown-credential-type","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}