{"record":{"id":"f39826f7ac977a69","repo":"phacility/phabricator","slug":"content-source-type-s-is-unknown","errorCode":null,"errorMessage":"Content source type \"%s\" is unknown.","messagePattern":"Content source type \"(.+?)\" is unknown\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/infrastructure/contentsource/PhabricatorContentSource.php","lineNumber":43,"sourceCode":"   * @param const The source type constant to build a source for.\n   * @param array Source parameters.\n   * @param bool True to suppress errors and force construction of a source\n   *   even if the source type is not valid.\n   * @return PhabricatorContentSource New source object.\n   */\n  final public static function newForSource(\n    $source,\n    array $params = array(),\n    $force = false) {\n\n    $map = self::getAllContentSources();\n    if (isset($map[$source])) {\n      $obj = clone $map[$source];\n    } else {\n      if ($force) {\n        $obj = new PhabricatorUnknownContentSource();\n      } else {\n        throw new Exception(\n          pht(\n            'Content source type \"%s\" is unknown.',\n            $source));\n      }\n    }\n\n    $obj->source = $source;\n    $obj->params = $params;\n\n    return $obj;\n  }\n\n  public static function newFromSerialized($serialized) {\n    $dict = json_decode($serialized, true);\n    if (!is_array($dict)) {\n      $dict = array();\n    }\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/contentsource/PhabricatorContentSource.php#L25-L61","documentation":"PhabricatorContentSource::newForSource($source, $params, $force) resolves the `$source` string against all PhabricatorContentSource subclasses (keyed by each class's SOURCECONST). If the string is not a registered source constant and `$force` is false, it throws. With `$force = true` it instead returns a PhabricatorUnknownContentSource placeholder.","triggerScenarios":"Loading stored content-source data (comments, transactions) whose source string no longer exists — e.g. an application providing a source was uninstalled — or calling newForSource with a typo'd/hand-built string instead of a class's SOURCECONST, with `$force` left at its false default.","commonSituations":"Uninstalling an application whose content source was recorded on old records; upgrading Phabricator where a source constant was renamed; custom code constructing sources from imported/migrated data.","solutions":["Use the source class's constant (e.g. PhabricatorWebContentSource::SOURCECONST) instead of a literal string.","When rendering historical/stored data that may predate current sources, call `newForSource($source, $params, true)` — it degrades to PhabricatorUnknownContentSource instead of throwing.","If a custom source disappeared, restore the class/extension that defines its SOURCECONST."],"exampleFix":"// before\n$source = PhabricatorContentSource::newForSource($stored_string, $params);\n// after: tolerate legacy values when rendering old records\n$source = PhabricatorContentSource::newForSource($stored_string, $params, true);","handlingStrategy":"fallback","validationCode":"$map = PhabricatorContentSource::getAllContentSources();\nif (!isset($map[$source_string])) {\n  // legacy/unknown value: render a placeholder instead of fataling\n  $source = PhabricatorContentSource::newForSource(\n    $source_string, $params, $force = true);\n} else {\n  $source = PhabricatorContentSource::newForSource($source_string, $params);\n}","typeGuard":"function isKnownContentSource($source) {\n  $map = PhabricatorContentSource::getAllContentSources();\n  return isset($map[$source]);\n}","tryCatchPattern":null,"preventionTips":["Only pass class SOURCECONST constants (e.g. PhabricatorWebContentSource::SOURCECONST) — never hand-typed strings.","When rendering stored/historical records, always use $force = true so uninstalled sources degrade gracefully.","If you uninstall an application that defines a content source, expect old records to reference it; keep the fallback path enabled."],"tags":["php","phabricator","content-source","data-migration"],"backgroundTag":"unknown-content-source","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}