{"record":{"id":"d0d74e32f2654d45","repo":"octobercms/october","slug":"value-must-be-of-type-array-for","errorCode":null,"errorMessage":"Value must be of type array for ","messagePattern":"Value must be of type array for ","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/dashboard/classes/ReportDimensionFilter.php","lineNumber":79,"sourceCode":"        }\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)) {\n            throw new SystemException('Invalid filter operation. Supported types: ' . implode(', ', $knownOperations));\n        }\n\n        if ($operation === self::OPERATION_ONE_OF && !is_array($value)) {\n            throw new SystemException('Value must be of type array for ' . self::OPERATION_ONE_OF . ' operation.');\n        } elseif ($operation !== self::OPERATION_ONE_OF && is_array($value)) {\n            throw new SystemException('Value cannot be of type array for ' . $operation . ' operation.');\n        }\n\n        $this->dataAttributeType = $dataAttributeType;\n        $this->attributeName = $attributeName;\n        $this->operation = $operation;\n        $this->value = $value;\n    }\n\n    /**\n     * Get the data attribute type\n     *\n     * @return string\n     */\n    public function getDataAttributeType(): string\n    {\n        return $this->dataAttributeType;","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/dashboard/classes/ReportDimensionFilter.php#L61-L97","documentation":"The OPERATION_ONE_OF filter matches a set of values, so its $value must be an array. The constructor throws when one_of is combined with a scalar, boolean, or any non-array value.","triggerScenarios":"new ReportDimensionFilter(ReportDimensionFilter::ATTR_TYPE_DIMENSION_FIELD, 'oc_field_status', ReportDimensionFilter::OPERATION_ONE_OF, 'active') — a single scalar where an array is required.","commonSituations":"Front-ends sending a single selected value instead of a list for multi-select controls; request payloads where the value is a string of comma-separated items that was never exploded.","solutions":["Wrap single values in an array: ['active'] instead of 'active'","Explode comma-separated input before constructing: array_map('trim', explode(',', $value))","Ensure multi-select UI controls always submit arrays (even with one selection)"],"exampleFix":"// before\n$filter = new ReportDimensionFilter(\n    ReportDimensionFilter::ATTR_TYPE_DIMENSION_FIELD,\n    'oc_field_status',\n    ReportDimensionFilter::OPERATION_ONE_OF,\n    'active'\n);\n\n// after\n$filter = new ReportDimensionFilter(\n    ReportDimensionFilter::ATTR_TYPE_DIMENSION_FIELD,\n    'oc_field_status',\n    ReportDimensionFilter::OPERATION_ONE_OF,\n    ['active']\n);","handlingStrategy":"validation","validationCode":"if ($operation === ReportDimensionFilter::OPERATION_ONE_OF && !is_array($value)) {\n    $value = is_string($value) && str_contains($value, ',')\n        ? array_map('trim', explode(',', $value))\n        : [$value];\n}\n$filter = new ReportDimensionFilter($type, $attribute, $operation, $value);","typeGuard":"function filterValueMatchesOperation(string $operation, mixed $value): bool\n{\n    return $operation === ReportDimensionFilter::OPERATION_ONE_OF\n        ? is_array($value)\n        : !is_array($value);\n}","tryCatchPattern":null,"preventionTips":["Make multi-select inputs always submit arrays, even with one selection","Explode comma-separated values server-side before building one_of filters","Add a request-boundary check pairing operation with value type"],"tags":["php","dashboard","report","filter","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}