{"record":{"id":"2a82bfd82fe5429a","repo":"octobercms/october","slug":"invalid-configuration-all-keys-must-be-non-empty","errorCode":null,"errorMessage":"Invalid configuration. All keys must be non-empty strings and values must be scalar.","messagePattern":"Invalid configuration\\. All keys must be non-empty strings and values must be scalar\\.","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/dashboard/classes/ReportDimension.php","lineNumber":420,"sourceCode":"    /**\n     * Allows setting default widget configuration values.\n     * The configuration is used for widgets created from this dimension\n     * through the quick widget creation feature. Currently, the future supports\n     * indicator-type dimensions only.\n     *\n     * @param array $config A name-value list of configuration parameters.\n     * All property names should be strings, and values should be scalar. The currently\n     * supported parameters are:\n     * - icon: Sets the default indicator icon CSS class.\n     * - title: Sets the default widget title.\n     * - link_text: Sets the default indicator link text.\n     * @return ReportDimension Returns the dimension object for chaining.\n     */\n    public function setDefaultWidgetConfig(array $config)\n    {\n        foreach ($config as $key => $value) {\n            if (!is_string($key) || empty($key) || !is_scalar($value)) {\n                throw new SystemException(\"Invalid configuration. All keys must be non-empty strings and values must be scalar.\");\n            }\n        }\n\n        $this->defaultWidgetConfig = $config;\n        return $this;\n    }\n\n    /**\n     * getDefaultWidgetConfig returns the default widget configuration.\n     */\n    public function getDefaultWidgetConfig(): array\n    {\n        return $this->defaultWidgetConfig;\n    }\n}\n","sourceCodeStart":402,"sourceCodeEnd":436,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/dashboard/classes/ReportDimension.php#L402-L436","documentation":"setDefaultWidgetConfig() stores a name-value list (documented keys: icon, title, link_text) that is applied as the default configuration for widgets generated from this dimension. To keep the config serializable into widget definitions it enforces that every key is a non-empty string and every value is scalar (string, int, float, bool).","triggerScenarios":"Calling setDefaultWidgetConfig(['title' => ['text' => 'Orders']]) (nested array value), setDefaultWidgetConfig([0 => 'x']) (integer key), or setDefaultWidgetConfig(['' => 'v']) (empty key). One invalid entry is enough — the whole loop throws.","commonSituations":"Passing a full widget configuration array (which contains nested arrays) instead of the flat default set; merging YAML/JSON config verbatim without flattening; values computed dynamically that end up as null or arrays.","solutions":["Pass only flat scalar entries: setDefaultWidgetConfig(['icon' => 'icon-check', 'title' => 'Orders', 'link_text' => 'View orders'])","If values come from external config, flatten or serialize nested values to strings/numbers before calling","Drop null entries — null is not scalar-safe in this check (is_scalar(null) === false)"],"exampleFix":"// before\n$dimension->setDefaultWidgetConfig([\n    'icon' => 'icon-check',\n    'title' => ['text' => 'Orders', 'level' => 2],\n]);\n\n// after\n$dimension->setDefaultWidgetConfig([\n    'icon' => 'icon-check',\n    'title' => 'Orders',\n]);","handlingStrategy":"validation","validationCode":"$clean = [];\nforeach ($config as $key => $value) {\n    if (!is_string($key) || $key === '' || !is_scalar($value)) {\n        throw new InvalidArgumentException(\"Invalid default widget config entry '{$key}'\");\n    }\n    $clean[$key] = $value;\n}\n$dimension->setDefaultWidgetConfig($clean);","typeGuard":"function isScalarWidgetConfig(array $config): bool\n{\n    foreach ($config as $key => $value) {\n        if (!is_string($key) || $key === '' || !is_scalar($value)) {\n            return false;\n        }\n    }\n    return true;\n}","tryCatchPattern":null,"preventionTips":["Keep default widget config flat: only icon, title, link_text style entries with scalar values","Serialize or flatten nested values before passing them in","Filter out null entries — null is not scalar"],"tags":["php","dashboard","report","dimension","widget-config","validation"],"backgroundTag":"config-validation-failed","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}