phacility/phabricator · error · Exception
Unknown type matched as image MIME type.
Error message
Unknown type matched as image MIME type.
What it means
Unreachable-default guard in isTransformableImage: the MIME type regex matched an image type (jpg/png/gif handled above), but the captured group was none of them — the pattern and switch have drifted apart. Indicates a code bug, not bad user data.
Solutions
- Update the regex or the switch so the matched MIME type groups stay in sync
- Add the missing case if a new image type is intended to be supported
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at src/applications/files/storage/PhabricatorFile.php:994 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/9f4fdd5e000b365d.
Report an issue: GitHub.
Appendix: source
Thrown at src/applications/files/storage/PhabricatorFile.php:994
$this->getViewableMimeType(),
$matches);
if (!$ok) {
return false;
}
switch ($matches[1]) {
case 'jpg';
case 'jpeg':
return function_exists('imagejpeg');
break;
case 'png':
return function_exists('imagepng');
break;
case 'gif':
return function_exists('imagegif');
break;
default:
throw new Exception(pht('Unknown type matched as image MIME type.'));
}
}
public static function getTransformableImageFormats() {
$supported = array();
if (function_exists('imagejpeg')) {
$supported[] = 'jpg';
}
if (function_exists('imagepng')) {
$supported[] = 'png';
}
if (function_exists('imagegif')) {
$supported[] = 'gif';
}
View on GitHub (pinned to 5720a38cfe)