phacility/phabricator · error · Exception

Found no background template resource for dimensions %dx%d.

Error message

Found no background template resource for dimensions %dx%d.

What it means

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.

Source

Thrown at src/applications/files/favicon/PhabricatorFaviconRef.php:395

      if ($width_diff < 0) {
        $scale_score = 1;
      } else {
        $scale_score = 0;
      }

      // Otherwise, we'd rather scale an image a little bit (ideally, zero)
      // than scale an image a lot.
      $width_score = abs($width_diff);

      $scores[$key] = id(new PhutilSortVector())
        ->addInt($default_score)
        ->addInt($scale_score)
        ->addInt($width_score);
    }

    if (!$scores) {
      if ($emblem === null) {
        throw new Exception(
          pht(
            'Found no background template resource for dimensions %dx%d.',
            $width,
            $height));
      } else {
        throw new Exception(
          pht(
            'Found no template resource (for emblem "%s") with dimensions '.
            '%dx%d.',
            $emblem,
            $width,
            $height));
      }
    }

    $scores = msortv($scores, 'getSelf');
    $best_score = head_key($scores);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Request dimension sets that the installed template resources actually cover (check what getAllResources() returns for background entries)
  2. Register background template resources covering the exact aspect ratio for those dimensions
  3. If this appears after an upgrade, diff the favicon resource definitions against the previous version and restore the missing entries
Defensive patterns

Strategy: validation

Validate before calling

// before requesting a favicon, confirm a same-aspect-ratio template exists
$covered = false;
$ratio = $width / $height;
foreach (self::getAllResources() as $resource) {
  if (idx($resource, 'emblem') !== null) { continue; }
  if (($resource['width'] / $resource['height']) === $ratio) { $covered = true; break; }
}
if (!$covered) { // use a known-good default size instead
}

Try / catch

catch Exception from favicon generation and fall back to a default favicon at supported dimensions.

Prevention

When it happens

Trigger: 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.

Common situations: Custom theming code requesting sizes like 180x180 without registering templates; extensions manipulating the favicon resource list; upstream changes to the built-in template set.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/7bf227364c494227. Report an issue: GitHub.