{"record":{"id":"b02d238878481df7","repo":"phacility/phabricator","slug":"credential-has-invalid-type-s-b02d23","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/PassphraseCredentialEditController.php","lineNumber":392,"sourceCode":"      ->setBackground(PHUIObjectBoxView::WHITE_CONFIG)\n      ->setForm($form);\n\n    $view = id(new PHUITwoColumnView())\n      ->setFooter(array(\n        $box,\n      ));\n\n    return $this->newPage()\n      ->setTitle($title)\n      ->setCrumbs($crumbs)\n      ->appendChild($view);\n  }\n\n  private function getCredentialType($type_const) {\n    $type = PassphraseCredentialType::getTypeByConstant($type_const);\n\n    if (!$type) {\n      throw new Exception(\n        pht('Credential has invalid type \"%s\"!', $type_const));\n    }\n\n    return $type;\n  }\n\n}\n","sourceCodeStart":374,"sourceCodeEnd":400,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/passphrase/controller/PassphraseCredentialEditController.php#L374-L400","documentation":"Thrown by the private helper PassphraseCredentialEditController::getCredentialType() when PassphraseCredentialType::getTypeByConstant() cannot map a type constant to an implementation. It fires on two paths: editing an existing credential whose stored constant is unresolvable (extension removed), or creating one with a bogus/unknown 'type' request parameter. Unlike the sibling controllers, this message correctly prints the offending constant.","triggerScenarios":"GET/POST /passphrase/edit/ with type=<not-a-registered-constant> (typo, stale link, HTML form tampering), or /passphrase/edit/<id>/ where the stored credentialType constant no longer resolves after an extension was disabled.","commonSituations":"Users hand-editing URLs; bookmarks to a type constant that an upgrade renamed; extension drift between environments; fuzzed or replayed form submissions.","solutions":["If creating: check the constant against array_keys(PassphraseCredentialType::getAllTypes()) and use a valid one from the create form's dropdown.","If editing an existing credential: verify its stored constant and reinstall the extension that provides it.","Validate the 'type' parameter server-side before looking it up, returning 404 for unknown constants."],"exampleFix":"// before\n$type_const = $request->getStr('type');\n$type = $this->getCredentialType($type_const);\n\n// after\n$type_const = $request->getStr('type');\n$valid = array_keys(PassphraseCredentialType::getAllTypes());\nif (!in_array($type_const, $valid, true)) {\n  return new Aphront404Response();\n}\n$type = $this->getCredentialType($type_const);","handlingStrategy":"validation","validationCode":"$valid = array_keys(PassphraseCredentialType::getAllTypes());\nif (!in_array($request->getStr('type'), $valid, true)) {\n  return new Aphront404Response();\n}","typeGuard":"function is_registered_credential_type($type_const) {\n  $all = PassphraseCredentialType::getAllTypes();\n  return is_string($type_const) && isset($all[$type_const]);\n}","tryCatchPattern":"try {\n  $type = PassphraseCredentialType::getTypeByConstant($type_const);\n} catch (Exception $ex) {\n  // treat as 404: unknown or stale type constant\n}","preventionTips":["Always route the 'type' request parameter through a whitelist of registered constants.","Generate type links from getAllTypes() so URLs never carry stale constants.","After upgrades, grep templates and docs for hardcoded type constants."],"tags":["phabricator","passphrase","credentials","validation","extension"],"backgroundTag":"unknown-credential-type","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}