octobercms/october · error · SystemException
Invalid configuration. All keys must be non-empty strings an
Error message
Invalid configuration. All keys must be non-empty strings and values must be scalar.
What it means
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).
Source
Thrown at modules/dashboard/classes/ReportDimension.php:420
/**
* Allows setting default widget configuration values.
* The configuration is used for widgets created from this dimension
* through the quick widget creation feature. Currently, the future supports
* indicator-type dimensions only.
*
* @param array $config A name-value list of configuration parameters.
* All property names should be strings, and values should be scalar. The currently
* supported parameters are:
* - icon: Sets the default indicator icon CSS class.
* - title: Sets the default widget title.
* - link_text: Sets the default indicator link text.
* @return ReportDimension Returns the dimension object for chaining.
*/
public function setDefaultWidgetConfig(array $config)
{
foreach ($config as $key => $value) {
if (!is_string($key) || empty($key) || !is_scalar($value)) {
throw new SystemException("Invalid configuration. All keys must be non-empty strings and values must be scalar.");
}
}
$this->defaultWidgetConfig = $config;
return $this;
}
/**
* getDefaultWidgetConfig returns the default widget configuration.
*/
public function getDefaultWidgetConfig(): array
{
return $this->defaultWidgetConfig;
}
}
View on GitHub (pinned to b608633a7e)
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)
Example fix
// before
$dimension->setDefaultWidgetConfig([
'icon' => 'icon-check',
'title' => ['text' => 'Orders', 'level' => 2],
]);
// after
$dimension->setDefaultWidgetConfig([
'icon' => 'icon-check',
'title' => 'Orders',
]); Defensive patterns
Strategy: validation
Validate before calling
$clean = [];
foreach ($config as $key => $value) {
if (!is_string($key) || $key === '' || !is_scalar($value)) {
throw new InvalidArgumentException("Invalid default widget config entry '{$key}'");
}
$clean[$key] = $value;
}
$dimension->setDefaultWidgetConfig($clean); Type guard
function isScalarWidgetConfig(array $config): bool
{
foreach ($config as $key => $value) {
if (!is_string($key) || $key === '' || !is_scalar($value)) {
return false;
}
}
return true;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.
Related errors
- Unknown dimension specified:
- The dimension field code cannot be empty.
- Display name cannot be empty.
- Unknown dimension type:
- Date dimensions cannot have fields.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/2a82bfd82fe5429a.
Report an issue: GitHub.