{"record":{"id":"6c72190ce4a5292b","repo":"octobercms/october","slug":"dropdown-menu-item-command-is-not-provided-for-ite","errorCode":null,"errorMessage":"Dropdown menu item command is not provided for item type :type","messagePattern":"Dropdown menu item command is not provided for item type :type","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/backend/vuecomponents/dropdownmenu/ItemDefinition.php","lineNumber":90,"sourceCode":"\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\n    /**\n     * setLinkHref\n     */\n    public function setLinkHref(string $value)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/vuecomponents/dropdownmenu/ItemDefinition.php#L72-L108","documentation":"The same ItemDefinition constructor also requires a non-empty command for every non-separator item, because a menu item signals selection by emitting that command string to the UI. Without a command the item would be unclickable, so construction fails fast rather than producing a dead menu entry.","triggerScenarios":"new ItemDefinition(ItemDefinition::TYPE_LINK, 'Open') with the third argument omitted; command strings built dynamically that end up as '' or null; swapping the label and command arguments.","commonSituations":"Renaming a handler and forgetting the menu item that emits it, leaving an empty string; building items from config arrays that lack a 'command' key; intending a separator but mistyping the type constant so the item is a regular type.","solutions":["Provide the command as the third argument: new ItemDefinition(ItemDefinition::TYPE_BUTTON, 'Save', 'save:all').","Default missing dynamic commands, e.g. $command = $data['command'] ?? 'noop';","Confirm separator items actually use ItemDefinition::TYPE_SEPARATOR if they are meant to omit the command."],"exampleFix":"// before\n$item = new ItemDefinition(ItemDefinition::TYPE_LINK, 'Open list');\n\n// after\n$item = new ItemDefinition(ItemDefinition::TYPE_LINK, 'Open list', 'open:list');","handlingStrategy":"validation","validationCode":"// Menu builder helper - validate commands coming from dynamic data\nfunction makeItem($type, $label, $command)\n{\n    if ($type !== ItemDefinition::TYPE_SEPARATOR && !strlen(trim((string) $command))) {\n        throw new InvalidArgumentException('Menu command missing for type ' . $type);\n    }\n    return new ItemDefinition($type, $label, $command);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default missing dynamic commands, e.g. $data['command'] ?? 'noop'","Use TYPE_SEPARATOR for dividers - the only command-less type","Keep handler names and the commands that emit them in one place"],"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"}