{"record":{"id":"8f96a66fe822fb83","repo":"phacility/phabricator","slug":"credential-has-invalid-type-s","errorCode":null,"errorMessage":"Credential has invalid type \"%s\"!","messagePattern":"Credential has invalid type \"(.+?)\"!","errorType":"exception","errorClass":"Exception","httpStatus":500,"severity":"error","filePath":"src/applications/passphrase/controller/PassphraseCredentialConduitController.php","lineNumber":33,"sourceCode":"          PhabricatorPolicyCapability::CAN_VIEW,\n          PhabricatorPolicyCapability::CAN_EDIT,\n        ))\n      ->executeOne();\n    if (!$credential) {\n      return new Aphront404Response();\n    }\n\n    $view_uri = '/K'.$credential->getID();\n\n    $token = id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(\n      $viewer,\n      $request,\n      $view_uri);\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    $is_locked = $credential->getIsLocked();\n\n    if ($is_locked) {\n      return $this->newDialog()\n        ->setUser($viewer)\n        ->setTitle(pht('Credential Locked'))\n        ->appendChild(\n          pht(\n            'This credential can not be made available via Conduit because '.\n            'it is locked.'))\n        ->addCancelButton($view_uri);\n    }\n\n    if ($request->isFormPost()) {\n      $xactions = array();\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/passphrase/controller/PassphraseCredentialConduitController.php#L15-L51","documentation":"Thrown by PassphraseCredentialConduitController when PassphraseCredentialType::getTypeByConstant() fails to resolve the credential's stored type constant to an installed credential type implementation, i.e. the database row references a type that no installed extension provides. Note an upstream quirk: the message formats the already-null $type instead of the stored constant, so you must read $credential->getCredentialType() yourself to learn the real constant.","triggerScenarios":"Opening /K<id>/conduit (the 'make available via Conduit' workflow, which itself requires a high-security session) for a credential whose credentialType column holds a constant from an uninstalled or removed custom PassphraseCredentialType subclass.","commonSituations":"A custom credential type class was deleted or renamed during a refactor; a third-party auth extension was deactivated in phabricator config; a database restored from an install that had extra extensions enabled.","solutions":["Inspect the stored constant: read $credential->getCredentialType() (credentialType column) for the affected K-object.","Compare it with the constants from PassphraseCredentialType::getAllTypes() to see what is actually registered in this install.","Re-enable or reinstall the extension that provides the missing type constant.","If the type is gone for good, destroy the stale credential and create a new one of a supported type."],"exampleFix":"// before\n$type = PassphraseCredentialType::getTypeByConstant(\n  $credential->getCredentialType());\nif (!$type) {\n  throw new Exception(pht('Credential has invalid type \"%s\"!', $type));\n}\n\n// after: report the actual constant, not the null lookup result\n$type_const = $credential->getCredentialType();\n$type = PassphraseCredentialType::getTypeByConstant($type_const);\nif (!$type) {\n  throw new Exception(\n    pht(\n      'Credential has invalid type \"%s\"!',\n      $type_const));\n}","handlingStrategy":"validation","validationCode":"$type_const = $credential->getCredentialType();\n$all = PassphraseCredentialType::getAllTypes();\nif (empty($all[$type_const])) {\n  // extension missing: reinstall it or destroy the stale credential\n}","typeGuard":"function credential_type_is_installed($credential) {\n  $all = PassphraseCredentialType::getAllTypes();\n  return isset($all[$credential->getCredentialType()]);\n}","tryCatchPattern":"try {\n  $type = PassphraseCredentialType::getTypeByConstant(\n    $credential->getCredentialType());\n} catch (Exception $ex) {\n  // log the stored constant, then prompt to reinstall the extension\n}","preventionTips":["Audit existing credentials with PassphraseCredentialType::getAllTypes() after disabling any extension.","Keep the same extension set enabled across environments that share a database.","Never rename a credential type's CREDENTIAL_TYPE constant without a storage migration."],"tags":["phabricator","passphrase","credentials","extension","configuration"],"backgroundTag":"unknown-credential-type","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}