octobercms/october · error · SystemException

Report widget data source class is not set

Error message

Report widget data source class is not set

What it means

HasWidgetData::getRequestedDataSource extracts the data source for a report widget request. It requires the widgetConfig array to contain a dataSource key; without it, a SystemException is thrown before DashManager is asked for the source. Report widgets bound to data sources must always carry dataSource in their configuration.

Source

Thrown at modules/dashboard/widgets/dash/HasWidgetData.php:286

    private function getDataSourceDimensionAndFields(ReportDataSourceBase $dataSource, string $dimensionCode): array
    {
        $result = [];

        $dimension = $this->findDimension($dataSource, $dimensionCode, false);
        if ($dimension) {
            $result[$dimension->getDataSetColumName()] = Lang::get($dimension->getDisplayName());
        }

        return $result;
    }

    /**
     * getRequestedDataSource
     */
    protected function getRequestedDataSource(array $widgetConfig): ReportDataSourceBase
    {
        if (!isset($widgetConfig['dataSource'])) {
            throw new SystemException('Report widget data source class is not set');
        }

        return $this->makeDataSource($widgetConfig['dataSource']);
    }
}

View on GitHub (pinned to b608633a7e)

Solutions

  1. Add dataSource: <fully qualified registered data source class> to the widget configuration.
  2. Recreate the widget through the dashboard UI so the default config (which includes dataSource) is applied.
  3. Validate saved definitions on load and reject/repair entries missing dataSource.
  4. Confirm the value is the class registered with registerDataSourceClass, not a display name.

Example fix

// before
$widgetConfig = ['type' => 'sum', 'dimension' => 'orders'];

// after
$widgetConfig = ['type' => 'sum', 'dimension' => 'orders', 'dataSource' => 'MyPlugin\Report\OrdersDataSource'];
Defensive patterns

Strategy: validation

Validate before calling

if (empty($widgetConfig['dataSource']) || !is_string($widgetConfig['dataSource'])) {
    throw new \ValidationException(['dataSource' => 'A registered data source class is required']);
}

Try / catch

try {
    $source = $this->getRequestedDataSource($widgetConfig);
} catch (\SystemException $e) {
    \Log::warning('Widget missing dataSource: '.json_encode($widgetConfig));
    return null;
}

Prevention

When it happens

Trigger: Loading dimension/metric data for a report widget whose config lacks dataSource; hand-built widget_config in AJAX payloads that only includes type and dimension; a saved dashboard definition where the dataSource property was dropped during editing or migration.

Common situations: Manually constructing widget configs in custom code instead of using the default configs from DashManager::getDefaultWidgetConfigs(); definitions edited in the database; older definitions created before dataSource became required.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/f109f1b0dbf27237. Report an issue: GitHub.