phacility/phabricator · error · Exception
Unknown dialog width '%s'!
Error message
Unknown dialog width '%s'!
What it means
AphrontDialogView::setWidth() accepts only the class constants WIDTH_DEFAULT ('default'), WIDTH_FORM ('form'), and WIDTH_FULL ('full'), which map to predefined CSS width classes. render() validates the stored width with a switch and throws on any other value — there are no numeric or arbitrary widths; the layout is CSS-class driven.
Source
Thrown at src/view/AphrontDialogView.php:317
__CLASS__));
}
$classes = array();
$classes[] = 'aphront-dialog-view';
$classes[] = $this->class;
if ($this->flush) {
$classes[] = 'aphront-dialog-flush';
}
switch ($this->width) {
case self::WIDTH_FORM:
case self::WIDTH_FULL:
$classes[] = 'aphront-dialog-view-width-'.$this->width;
break;
case self::WIDTH_DEFAULT:
break;
default:
throw new Exception(
pht(
"Unknown dialog width '%s'!",
$this->width));
}
if ($this->isStandalone) {
$classes[] = 'aphront-dialog-view-standalone';
}
if ($this->objectList) {
$classes[] = 'aphront-dialog-object-list';
}
$attributes = array(
'class' => implode(' ', $classes),
'sigil' => 'jx-dialog',
'role' => 'dialog',
);View on GitHub (pinned to 5720a38cfe)
Solutions
- Use the class constants: setWidth(AphrontDialogView::WIDTH_FORM) or WIDTH_FULL; omit setWidth() for the default width.
- If the value comes from config/user input, map it through a whitelist of the three constants and fall back to WIDTH_DEFAULT for anything else.
- For custom widths you would need a custom dialog class — do not pass raw strings here.
Example fix
// before
$dialog->setWidth('600px');
// after
$dialog->setWidth(AphrontDialogView::WIDTH_FORM); Defensive patterns
Strategy: type-guard
Validate before calling
// Whitelist any dynamic width before handing it to the view: $valid = array( AphrontDialogView::WIDTH_DEFAULT => true, AphrontDialogView::WIDTH_FORM => true, AphrontDialogView::WIDTH_FULL => true, ); $width = isset($valid[$width]) ? $width : AphrontDialogView::WIDTH_DEFAULT; $dialog->setWidth($width);
Type guard
// Narrow to the three legal width constants:
function is_valid_dialog_width($width) {
$valid = array(
AphrontDialogView::WIDTH_DEFAULT => true,
AphrontDialogView::WIDTH_FORM => true,
AphrontDialogView::WIDTH_FULL => true,
);
return isset($valid[$width]);
} Prevention
- Always pass the WIDTH_* class constants, never string or pixel literals.
- Never forward user input or config values into setWidth() without whitelisting against the constants.
- Remember widths are CSS classes, not sizes — there is no numeric width to set.
When it happens
Trigger: Calling setWidth() with anything other than 'default', 'form', or 'full' — e.g. setWidth('600px'), setWidth('wide'), setWidth(600), or passing an unvalidated user/config value straight into setWidth().
Common situations: Trying to set a pixel width from another UI framework's habits; feeding a width from a config file or request parameter without whitelisting; typos like 'Full' or 'form ' (case and whitespace matter).
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- You must call %s when rendering an %s.
- Service "%s" is unrecognized, restricted, or you do not have
- When creating a new Almanac interface via the Conduit API, y
- Device "%s" is unrecognized, restricted, or you do not have
- Interfaces must have a unique combination of network, device
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/3b7d570f7d1106c8.
Report an issue: GitHub.