{"record":{"id":"a9f267ac9613b56b","repo":"octobercms/october","slug":"please-select-a-widget-to-add","errorCode":null,"errorMessage":"Please select a widget to add.","messagePattern":"Please select a widget to add\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/backend/widgets/ReportContainer.php","lineNumber":250,"sourceCode":"        $this->vars['widgets'] = DashManager::instance()->listReportWidgets();\n\n        return $this->makePartial('new_widget_popup');\n    }\n\n    /**\n     * onAddWidget\n     */\n    public function onAddWidget()\n    {\n        if (!$this->showAddRemove) {\n            throw new ForbiddenException;\n        }\n\n        $className = trim(Request::input('className'));\n        $size = trim(Request::input('size'));\n\n        if (!$className) {\n            throw new ApplicationException(\"Please select a widget to add.\");\n        }\n\n        if (!class_exists($className)) {\n            throw new ApplicationException(\"The selected class doesn't exist.\");\n        }\n\n        $widget = new $className($this->controller);\n        if (!($widget instanceof \\Backend\\Classes\\ReportWidgetBase)) {\n            throw new ApplicationException(\"The selected class is not a report widget.\");\n        }\n\n        $widgetInfo = $this->addWidget($widget, $size);\n\n        return [\n            '@#'.$this->getId('container-list') => $this->makePartial('widget', [\n                'widget' => $widget,\n                'widgetAlias' => $widgetInfo['alias'],\n                'sortOrder' => $widgetInfo['sortOrder']","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/widgets/ReportContainer.php#L232-L268","documentation":"Input guard in the onAddWidget AJAX handler of the dashboard report container: after the permission check passes, it reads the 'className' POST field and throws when it is empty. This means the 'add widget' request arrived without a selected widget class — a UI bug where the dropdown submitted nothing, or a hand-crafted request.","triggerScenarios":"Thrown at modules/backend/widgets/ReportContainer.php:250 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the add-widget popup always posts a non-empty className (preselect a default widget in the dropdown)","Validate on the client that a widget is selected before submitting the request"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","contentChangedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}