octobercms/october · error · SystemException
Attribute name must be empty for
Error message
Attribute name must be empty for
What it means
For ATTR_TYPE_DIMENSION filters the target is the dimension itself, so the constructor forbids an attribute name — a non-empty $attributeName combined with the plain dimension type is contradictory and throws a SystemException.
Source
Thrown at modules/dashboard/classes/ReportDimensionFilter.php:56
* One of the OPERATION_* constants.
* @param string|array|int|float|bool $value Specifies the filter value.
*/
public function __construct(string $dataAttributeType, ?string $attributeName, string $operation, string|array|int|float|bool $value)
{
$knownAttributeTypes = [
self::ATTR_TYPE_DIMENSION,
self::ATTR_TYPE_DIMENSION_FIELD
];
if (!in_array($dataAttributeType, $knownAttributeTypes)) {
throw new SystemException('Invalid data attribute type. Supported types: ' . implode(', ', $knownAttributeTypes));
}
if (!strlen($attributeName) && $dataAttributeType !== self::ATTR_TYPE_DIMENSION) {
throw new SystemException('Attribute name cannot be empty for ' . $dataAttributeType . ' data attribute type.');
}
if (strlen($attributeName) && $dataAttributeType === self::ATTR_TYPE_DIMENSION) {
throw new SystemException('Attribute name must be empty for ' . self::ATTR_TYPE_DIMENSION . ' data attribute type.');
}
if ($dataAttributeType === self::ATTR_TYPE_DIMENSION_FIELD) {
ReportDimensionField::validateCode($attributeName);
}
$knownOperations = [
self::OPERATION_EQUALS,
self::OPERATION_MORE_OR_EQUALS,
self::OPERATION_LESS_OR_EQUALS,
self::OPERATION_MORE,
self::OPERATION_LESS,
self::OPERATION_STARTS_WITH,
self::OPERATION_STRING_INCLUDES,
self::OPERATION_ONE_OF
];
if (!in_array($operation, $knownOperations)) {View on GitHub (pinned to b608633a7e)
Solutions
- Pass null (or '') as the attribute name when the filter type is ATTR_TYPE_DIMENSION
- Use ATTR_TYPE_DIMENSION_FIELD with the field code when you actually want to filter a field
- Centralize the type/attribute pairing rules in one factory method so callers cannot mismatch them
Example fix
// before
$filter = new ReportDimensionFilter(
ReportDimensionFilter::ATTR_TYPE_DIMENSION,
'oc_field_status',
ReportDimensionFilter::OPERATION_EQUALS,
5
);
// after
$filter = new ReportDimensionFilter(
ReportDimensionFilter::ATTR_TYPE_DIMENSION,
null,
ReportDimensionFilter::OPERATION_EQUALS,
5
); Defensive patterns
Strategy: validation
Validate before calling
$attributeName = $type === ReportDimensionFilter::ATTR_TYPE_DIMENSION
? null
: $attributeName;
$filter = new ReportDimensionFilter($type, $attributeName, $operation, $value); Type guard
function filterTypeMatchesAttribute(string $type, ?string $attribute): bool
{
return $type === ReportDimensionFilter::ATTR_TYPE_DIMENSION
? ($attribute === null || $attribute === '')
: (is_string($attribute) && $attribute !== '');
} Prevention
- Never pass an attribute name with ATTR_TYPE_DIMENSION
- Build filters through a single factory that encodes the type/attribute pairing rules
- Log type+attribute pairs during development to catch mismatches early
When it happens
Trigger: new ReportDimensionFilter(ReportDimensionFilter::ATTR_TYPE_DIMENSION, 'oc_field_status', ReportDimensionFilter::OPERATION_EQUALS, 5) — attribute name set while dataAttributeType is 'dimension'.
Common situations: A single filter-building routine that always passes an attribute string, forgetting to null it for dimension-level filters; refactoring a field filter to a dimension filter without clearing the attribute.
Related errors
- Invalid data attribute type. Supported types:
- Attribute name cannot be empty for
- Invalid filter operation. Supported types:
- Value must be of type array for
- Value cannot be of type array for
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/dcd86ae73d947783.
Report an issue: GitHub.