octobercms/october · error · SystemException
Attribute name cannot be empty for
Error message
Attribute name cannot be empty for
What it means
A filter of type ATTR_TYPE_DIMENSION_FIELD targets a specific field of a dimension, so the constructor requires a non-empty $attributeName carrying that field's code. Passing null or '' with a non-dimension type throws a SystemException.
Source
Thrown at modules/dashboard/classes/ReportDimensionFilter.php:52
* @param ?string $attributeName Specifies the attribute name, e.g. a dimension field code.
* Must not be null if the data attribute type is ATTR_TYPE_DIMENSION_FIELD.
* Must be null if the data attribute type is ATTR_TYPE_DIMENSION.
* @param bool $operation Specifies the filter operation.
* 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,View on GitHub (pinned to b608633a7e)
Solutions
- Supply the dimension field code as the attribute name, e.g. 'oc_field_status'
- If the intent is to filter the dimension column itself, use ATTR_TYPE_DIMENSION with a null attribute name instead
- Validate that the incoming payload contains a non-empty attribute before constructing the filter
Example fix
// before
$filter = new ReportDimensionFilter(
ReportDimensionFilter::ATTR_TYPE_DIMENSION_FIELD,
$payload['attribute'] ?? null,
ReportDimensionFilter::OPERATION_EQUALS,
'active'
);
// after
if (empty($payload['attribute'])) {
throw new InvalidArgumentException('attribute is required for dimension_field filters');
}
$filter = new ReportDimensionFilter(
ReportDimensionFilter::ATTR_TYPE_DIMENSION_FIELD,
$payload['attribute'],
ReportDimensionFilter::OPERATION_EQUALS,
'active'
); Defensive patterns
Strategy: validation
Validate before calling
$attribute = $payload['attribute'] ?? null;
if ($type === ReportDimensionFilter::ATTR_TYPE_DIMENSION_FIELD && (!is_string($attribute) || $attribute === '')) {
throw new InvalidArgumentException('attribute is required for dimension_field filters');
} Prevention
- Pair the type with its attribute rule in one factory: dimension => null, dimension_field => non-empty oc_field_ code
- Reject filter payloads missing the attribute for field filters at the boundary
- Remember the attribute for field filters must also pass the oc_field_ code validation
When it happens
Trigger: new ReportDimensionFilter(ReportDimensionFilter::ATTR_TYPE_DIMENSION_FIELD, null, ReportDimensionFilter::OPERATION_EQUALS, 'active') or with '' as the second argument.
Common situations: Building filters from request arrays where the attribute key is missing (null coalescing to null); copy-paste of a dimension-type filter without adding the field code; front-ends that omit the field selector when the user did not pick one.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- Invalid data attribute type. Supported types:
- Invalid filter operation. Supported types:
- Invalid configuration. All keys must be non-empty strings an
- The dimension field code cannot be empty.
- Display name cannot be empty.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/148e216426d429ed.
Report an issue: GitHub.