{"record":{"id":"b93f85a10fa3106b","repo":"phacility/phabricator","slug":"menu-item-s-is-not-a-label","errorCode":null,"errorMessage":"Menu item '%s' is not a label!","messagePattern":"Menu item '(.+?)' is not a label!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/view/phui/PHUIListView.php","lineNumber":109,"sourceCode":"\n    $result = array();\n    foreach ($this->items as $other) {\n      if ($other->getKey() == $key) {\n        $result[] = $item;\n      }\n      $result[] = $other;\n    }\n\n    $this->items = $result;\n    return $this;\n  }\n\n  public function addMenuItemToLabel($key, PHUIListItemView $item) {\n    $this->requireKey($key);\n\n    $other = $this->getItem($key);\n    if ($other->getType() != PHUIListItemView::TYPE_LABEL) {\n      throw new Exception(pht(\"Menu item '%s' is not a label!\", $key));\n    }\n\n    $seen = false;\n    $after = null;\n    foreach ($this->items as $other) {\n      if (!$seen) {\n        if ($other->getKey() == $key) {\n          $seen = true;\n        }\n      } else {\n        if ($other->getType() == PHUIListItemView::TYPE_LABEL) {\n          break;\n        }\n      }\n      $after = $other->getKey();\n    }\n\n    return $this->addMenuItemAfter($after, $item);","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/view/phui/PHUIListView.php#L91-L127","documentation":"PHUIListView::addMenuItemToLabel($key, $item) appends $item into the section opened by the label item with key $key — it scans forward from that item until the next TYPE_LABEL item. The target must actually be a label, i.e. a PHUIListItemView created with setType(PHUIListItemView::TYPE_LABEL); if the key resolves to a link, spacer, divider, or button item, this exception is thrown.","triggerScenarios":"Calling addMenuItemToLabel('actions', $item) where the 'actions' item was created with the default TYPE_LINK type and never given setType(PHUIListItemView::TYPE_LABEL).","commonSituations":"Building grouped side menus and forgetting setType() on the group header; assuming setName() alone makes an item a label; refactoring menus so a header item is created through a generic factory.","solutions":["Create the target with ->setKey($key) and ->setType(PHUIListItemView::TYPE_LABEL) before calling addMenuItemToLabel().","Probe the target first: $list->getItem($key)->getType() must equal PHUIListItemView::TYPE_LABEL.","If section grouping is not needed, use addMenuItemAfter() with an explicit anchor instead."],"exampleFix":"// before\n$list->addMenuItem(\n  id(new PHUIListItemView())\n    ->setKey('actions')\n    ->setName(pht('Actions'))); // default TYPE_LINK\n$list->addMenuItemToLabel('actions', $item); // throws: not a label\n\n// after\n$list->addMenuItem(\n  id(new PHUIListItemView())\n    ->setKey('actions')\n    ->setType(PHUIListItemView::TYPE_LABEL)\n    ->setName(pht('Actions')));\n$list->addMenuItemToLabel('actions', $item);","handlingStrategy":"validation","validationCode":"$target = $list->getItem($key);\nif ($target && $target->getType() === PHUIListItemView::TYPE_LABEL) {\n  $list->addMenuItemToLabel($key, $item);\n}","typeGuard":"function isLabelItem(PHUIListItemView $item) {\n  return $item->getType() === PHUIListItemView::TYPE_LABEL;\n}","tryCatchPattern":null,"preventionTips":["Group headers must be TYPE_LABEL items with stable keys.","Always pair setType(PHUIListItemView::TYPE_LABEL) with setName() when creating section headers.","Check getType() before any keyed operation that assumes a label."],"tags":["php","phabricator","menu","label","list-view"],"backgroundTag":"menu-item-type-mismatch","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}