{"record":{"id":"f48f794ce4c6a8cf","repo":"octobercms/october","slug":"backend-lang-field-invalid-type","errorCode":"backend::lang.field.invalid_type","errorMessage":"Invalid field type used :type.","messagePattern":"Invalid field type used :type\\.","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/dashboard/widgets/Dash.php","lineNumber":453,"sourceCode":"                $name = $widget['reportName'] ?? 'custom_report_' . str_random();\n                $this->allReports[$name] = $this->makeDashReport((string) $name, $widget);\n            }\n        }\n    }\n\n    /**\n     * makeDashReport creates a dash report object from name and configuration\n     */\n    protected function makeDashReport(string $name, $config = []): DashReport\n    {\n        $report = new DashReport([\n            'reportName' => $name,\n            'label' => $config['label'] ?? null,\n        ]);\n\n        $reportType = $config['type'] ?? null;\n        if (!is_string($reportType) && $reportType !== null) {\n            throw new SystemException(Lang::get(\n                'backend::lang.field.invalid_type',\n                ['type' => gettype($reportType)]\n            ));\n        }\n\n        if ($config) {\n            $report->useConfig($config);\n        }\n\n        if ($reportType) {\n            $report->displayAs($reportType);\n        }\n\n        return $report;\n    }\n\n    /**\n     * loadInitialState for the dashboards","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/dashboard/widgets/Dash.php#L435-L471","documentation":"Dash::makeDashReport builds a DashReport from a name and config array; the type key drives displayAs(). Winter/October requires type to be a string (or absent). If the config carries a non-string type - array, integer, boolean - a SystemException with the backend::lang.field.invalid_type message is thrown before the widget is created. It is a config-format guard, not a runtime data error.","triggerScenarios":"A dashboard definition (YAML or saved JSON definition) contains type: [sum, avg] or type: 10 or type: true for a report; programmatic calls like $dash->makeReport('sales', ['type' => ['sum']]); POSTed widget configuration where type arrives as a nested array from a malformed form payload.","commonSituations":"Hand-edited dashboard YAML using YAML list syntax for a scalar; a migration or seed script assigning type from an uncast database column; type coming from user input that was never cast to string; version upgrades where a widget type key changed shape.","solutions":["Fix the definition so type is a single string, e.g. type: sum instead of type: [sum].","Cast before building: pass ['type' => (string) $type] when the value comes from storage or user input.","Remove the type key entirely if the default report type is intended.","Validate the definition payload (YAML lint / JSON schema) before it reaches the dashboard widget."],"exampleFix":"# before (dashboard definition)\nreports:\n  sales:\n    type: [sum]\n# after\nreports:\n  sales:\n    type: sum","handlingStrategy":"type-guard","validationCode":"$type = $config['type'] ?? null;\nif ($type !== null && !is_string($type)) {\n    throw new \\InvalidArgumentException('report type must be a string');\n}","typeGuard":"/** True when the report config's type key is safe for Dash. */\nfunction isValidReportType(array $config): bool\n{\n    $t = $config['type'] ?? null;\n    return $t === null || is_string($t);\n}","tryCatchPattern":"try {\n    $dash->makeReport($name, $config);\n} catch (\\SystemException $e) {\n    // config came from user/storage: report which key is malformed\n    \\Log::warning('Bad report config for '.$name.': '.json_encode($config));\n}","preventionTips":["Validate dashboard definitions with a schema (JSON/YAML lint) before importing them.","Cast type to string when sourcing it from database columns or request input.","Document the allowed type strings per widget in the plugin's README."],"tags":["dashboard","config","type-validation","yaml"],"backgroundTag":"invalid-config-type","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}