{"record":{"id":"2da2fb1839630b3c","repo":"octobercms/october","slug":"dropdown-menu-item-label-is-not-provided-for-item","errorCode":null,"errorMessage":"Dropdown menu item label is not provided for item type :type","messagePattern":"Dropdown menu item label is not provided for item type :type","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/backend/vuecomponents/dropdownmenu/ItemDefinition.php","lineNumber":86,"sourceCode":"    /**\n     * @var string|null key\n     */\n    protected $key = null;\n\n    /**\n     * @var string|null group\n     */\n    protected $group;\n\n    /**\n     * __construct\n     */\n    public function __construct($type, ?string $label = null, ?string $command = null)\n    {\n        $this->type = $type;\n\n        if ($type != ItemDefinition::TYPE_SEPARATOR && !strlen($label)) {\n            throw new SystemException('Dropdown menu item label is not provided for item type '.$type);\n        }\n\n        if ($type != ItemDefinition::TYPE_SEPARATOR && !strlen($command)) {\n            throw new SystemException('Dropdown menu item command is not provided for item type '.$type);\n        }\n\n        $this->label = $label;\n        $this->command = $command;\n    }\n\n    /**\n     * Sets optional item key attribute\n     */\n    public function setKey(string $value)\n    {\n        $this->key = $value;\n    }\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/vuecomponents/dropdownmenu/ItemDefinition.php#L68-L104","documentation":"ItemDefinition is the PHP value object behind backend dropdown menus. Its constructor requires a non-empty label for every item type except TYPE_SEPARATOR (separators render a dividing line, not text). Instantiating any visible item without a label throws immediately at construction time.","triggerScenarios":"new ItemDefinition(ItemDefinition::TYPE_LINK) with the second argument omitted (defaults to null); menu builders that read labels from data or localization and get null/empty for some rows.","commonSituations":"Menu items built from database rows where the label column is null; forgetting that separators are the only label-less type; passing label and command in the wrong order (type, label, command).","solutions":["Pass a non-empty label as the second constructor argument: new ItemDefinition(ItemDefinition::TYPE_LINK, 'Open', 'openTab').","Guard dynamic data: skip or default items whose label is null/empty before constructing.","Use ItemDefinition::TYPE_SEPARATOR for visual dividers — the only type allowed to omit label and command."],"exampleFix":"// before\n$item = new ItemDefinition(ItemDefinition::TYPE_LINK);\n\n// after\n$item = new ItemDefinition(ItemDefinition::TYPE_LINK, 'Open in new tab', 'openTab');\n\n// separator is the only label-less type\n$sep = new ItemDefinition(ItemDefinition::TYPE_SEPARATOR);","handlingStrategy":"validation","validationCode":"// Menu builder helper - validate labels coming from dynamic data\nfunction makeItem($type, $label, $command)\n{\n    if ($type !== ItemDefinition::TYPE_SEPARATOR && !strlen(trim((string) $label))) {\n        throw new InvalidArgumentException('Menu label missing for type ' . $type);\n    }\n    return new ItemDefinition($type, $label, $command);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default labels from localization with a visible fallback","Skip data rows with empty labels instead of constructing items from them","Remember the constructor order: type, label, command"],"tags":["dropdown-menu","menu","php","constructor-argument"],"backgroundTag":"missing-constructor-argument","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}