{"record":{"id":"dcd86ae73d947783","repo":"octobercms/october","slug":"attribute-name-must-be-empty-for-dcd86a","errorCode":null,"errorMessage":"Attribute name must be empty for ","messagePattern":"Attribute name must be empty for ","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/dashboard/classes/ReportDimensionFilter.php","lineNumber":56,"sourceCode":"     * One of the OPERATION_* constants.\n     * @param string|array|int|float|bool $value Specifies the filter value.\n     */\n    public function __construct(string $dataAttributeType, ?string $attributeName, string $operation, string|array|int|float|bool $value)\n    {\n        $knownAttributeTypes = [\n            self::ATTR_TYPE_DIMENSION,\n            self::ATTR_TYPE_DIMENSION_FIELD\n        ];\n        if (!in_array($dataAttributeType, $knownAttributeTypes)) {\n            throw new SystemException('Invalid data attribute type. Supported types: ' . implode(', ', $knownAttributeTypes));\n        }\n\n        if (!strlen($attributeName) && $dataAttributeType !== self::ATTR_TYPE_DIMENSION) {\n            throw new SystemException('Attribute name cannot be empty for ' . $dataAttributeType . ' data attribute type.');\n        }\n\n        if (strlen($attributeName) && $dataAttributeType === self::ATTR_TYPE_DIMENSION) {\n            throw new SystemException('Attribute name must be empty for ' . self::ATTR_TYPE_DIMENSION . ' data attribute type.');\n        }\n\n        if ($dataAttributeType === self::ATTR_TYPE_DIMENSION_FIELD) {\n            ReportDimensionField::validateCode($attributeName);\n        }\n\n        $knownOperations = [\n            self::OPERATION_EQUALS,\n            self::OPERATION_MORE_OR_EQUALS,\n            self::OPERATION_LESS_OR_EQUALS,\n            self::OPERATION_MORE,\n            self::OPERATION_LESS,\n            self::OPERATION_STARTS_WITH,\n            self::OPERATION_STRING_INCLUDES,\n            self::OPERATION_ONE_OF\n        ];\n\n        if (!in_array($operation, $knownOperations)) {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/dashboard/classes/ReportDimensionFilter.php#L38-L74","documentation":"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.","triggerScenarios":"new ReportDimensionFilter(ReportDimensionFilter::ATTR_TYPE_DIMENSION, 'oc_field_status', ReportDimensionFilter::OPERATION_EQUALS, 5) — attribute name set while dataAttributeType is 'dimension'.","commonSituations":"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.","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"],"exampleFix":"// before\n$filter = new ReportDimensionFilter(\n    ReportDimensionFilter::ATTR_TYPE_DIMENSION,\n    'oc_field_status',\n    ReportDimensionFilter::OPERATION_EQUALS,\n    5\n);\n\n// after\n$filter = new ReportDimensionFilter(\n    ReportDimensionFilter::ATTR_TYPE_DIMENSION,\n    null,\n    ReportDimensionFilter::OPERATION_EQUALS,\n    5\n);","handlingStrategy":"validation","validationCode":"$attributeName = $type === ReportDimensionFilter::ATTR_TYPE_DIMENSION\n    ? null\n    : $attributeName;\n$filter = new ReportDimensionFilter($type, $attributeName, $operation, $value);","typeGuard":"function filterTypeMatchesAttribute(string $type, ?string $attribute): bool\n{\n    return $type === ReportDimensionFilter::ATTR_TYPE_DIMENSION\n        ? ($attribute === null || $attribute === '')\n        : (is_string($attribute) && $attribute !== '');\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["php","dashboard","report","filter","argument-mismatch"],"backgroundTag":"invalid-argument-combination","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}