{"record":{"id":"7d3a398fde9e3e84","repo":"octobercms/october","slug":"the-selected-class-is-not-a-report-widget","errorCode":null,"errorMessage":"The selected class is not a report widget.","messagePattern":"The selected class is not a report widget\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/backend/widgets/ReportContainer.php","lineNumber":259,"sourceCode":"    {\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']\n            ])\n        ];\n    }\n\n    /**\n     * onSetWidgetOrders\n     */\n    public function onSetWidgetOrders()\n    {","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/widgets/ReportContainer.php#L241-L277","documentation":"Type guard in onAddWidget: the posted class exists and was instantiated, but the resulting object is not an instance of Backend\\Classes\\ReportWidgetBase. The dashboard can only host report widgets, so any other class (a form widget, controller, or arbitrary class) is rejected before being added.","triggerScenarios":"Thrown at modules/backend/widgets/ReportContainer.php:259 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Extend Backend\\Classes\\ReportWidgetBase in the widget class being added","Select a genuine report widget from the dashboard's available widget list instead of an arbitrary class"],"exampleFix":null,"handlingStrategy":"type-guard","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"}