{"record":{"id":"7bf227364c494227","repo":"phacility/phabricator","slug":"found-no-background-template-resource-for-dimensio","errorCode":null,"errorMessage":"Found no background template resource for dimensions %dx%d.","messagePattern":"Found no background template resource for dimensions (.+?)x(.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/files/favicon/PhabricatorFaviconRef.php","lineNumber":395,"sourceCode":"      if ($width_diff < 0) {\n        $scale_score = 1;\n      } else {\n        $scale_score = 0;\n      }\n\n      // Otherwise, we'd rather scale an image a little bit (ideally, zero)\n      // than scale an image a lot.\n      $width_score = abs($width_diff);\n\n      $scores[$key] = id(new PhutilSortVector())\n        ->addInt($default_score)\n        ->addInt($scale_score)\n        ->addInt($width_score);\n    }\n\n    if (!$scores) {\n      if ($emblem === null) {\n        throw new Exception(\n          pht(\n            'Found no background template resource for dimensions %dx%d.',\n            $width,\n            $height));\n      } else {\n        throw new Exception(\n          pht(\n            'Found no template resource (for emblem \"%s\") with dimensions '.\n            '%dx%d.',\n            $emblem,\n            $width,\n            $height));\n      }\n    }\n\n    $scores = msortv($scores, 'getSelf');\n    $best_score = head_key($scores);\n","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/favicon/PhabricatorFaviconRef.php#L377-L413","documentation":"PhabricatorFaviconRef::newTemplateFile() scores every registered template resource and requires an exact aspect-ratio match for the requested dimensions; if no candidate survives (the $scores array is empty), it throws. With emblem === null this variant reports that no background template exists for the requested width x height. In practice this means the template resource set does not cover those dimensions at all.","triggerScenarios":"Asking favicon generation for width/height whose aspect ratio (or emblem slot) has no entry in getAllResources() — typically custom code requesting non-standard sizes, or a template map altered by an extension or upgrade so the default background templates no longer match.","commonSituations":"Custom theming code requesting sizes like 180x180 without registering templates; extensions manipulating the favicon resource list; upstream changes to the built-in template set.","solutions":["Request dimension sets that the installed template resources actually cover (check what getAllResources() returns for background entries)","Register background template resources covering the exact aspect ratio for those dimensions","If this appears after an upgrade, diff the favicon resource definitions against the previous version and restore the missing entries"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before requesting a favicon, confirm a same-aspect-ratio template exists\n$covered = false;\n$ratio = $width / $height;\nforeach (self::getAllResources() as $resource) {\n  if (idx($resource, 'emblem') !== null) { continue; }\n  if (($resource['width'] / $resource['height']) === $ratio) { $covered = true; break; }\n}\nif (!$covered) { // use a known-good default size instead\n}","typeGuard":null,"tryCatchPattern":"catch Exception from favicon generation and fall back to a default favicon at supported dimensions.","preventionTips":["Request only dimension sets covered by registered templates","When adding sizes, register matching template resources in the same change"],"tags":["favicon","rendering","resources","dimensions","aspect-ratio"],"backgroundTag":"missing-template-resource","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}