{"record":{"id":"5f9f48e9d6ee5e50","repo":"cakephp/cakephp","slug":"s-is-not-a-valid-index-option","errorCode":null,"errorMessage":"\"%s\" is not a valid index option.","messagePattern":"\"(.+?)\" is not a valid index option\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Database/Schema/Index.php","lineNumber":309,"sourceCode":"    public function getAccessMethod(): ?string\n    {\n        return $this->accessMethod;\n    }\n\n    /**\n     * Utility method that maps an array of index options to this object's methods.\n     *\n     * @param array<string, mixed> $attributes Attributes to set.\n     * @throws \\RuntimeException\n     * @return $this\n     */\n    public function setAttributes(array $attributes)\n    {\n        // Valid Options\n        $validOptions = ['columns', 'type', 'name', 'length', 'order', 'include', 'where', 'accessMethod'];\n        foreach ($attributes as $attr => $value) {\n            if (!in_array($attr, $validOptions, true)) {\n                throw new RuntimeException(sprintf('\"%s\" is not a valid index option.', $attr));\n            }\n            $method = 'set' . ucfirst($attr);\n            $this->$method($value);\n        }\n\n        return $this;\n    }\n\n    /**\n     * Convert an index into an array that is compatible with the Index constructor.\n     *\n     * @return array<string, mixed>\n     */\n    public function toArray(): array\n    {\n        $result = [\n            'name' => $this->getName(),\n            'columns' => $this->getColumns(),","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/cakephp/cakephp/blob/1128eba9b09f1946df684811350e26f2cef68fac/src/Database/Schema/Index.php#L291-L327","documentation":"Index::setAttributes() validates each key of the attributes array against a whitelist: columns, type, name, length, order, include, where, accessMethod. Any other key throws RuntimeException naming the offending attribute, preventing silently ignored index options.","triggerScenarios":"Calling $table->addIndex(...)->setAttributes(['column' => ['x']]) (singular 'column' instead of 'columns'), or passing options like 'unique' or 'uniqueIndex' that belong elsewhere (the type option).","commonSituations":"Typo in index option names; passing column-level options (like 'default') to an index; migrating config from another tool with different index option vocabulary.","solutions":["Fix the attribute name to one of: columns, type, name, length, order, include, where, accessMethod","Use ['type' => 'unique'] instead of a 'unique' key for unique indexes","Validate dynamically-built attribute arrays against the whitelist before calling setAttributes"],"exampleFix":"// before\n$index->setAttributes(['column' => ['user_id']]);\n// after\n$index->setAttributes(['columns' => ['user_id']]);","handlingStrategy":"validation","validationCode":"$valid = ['columns','type','name','length','order','include','where','accessMethod'];\n$bad = array_diff(array_keys($attrs), $valid);\nif ($bad) { throw new InvalidArgumentException('Unknown index options: ' . implode(',', $bad)); }\n$index->setAttributes($attrs);","typeGuard":null,"tryCatchPattern":"try {\n    $index->setAttributes($attrs);\n} catch (\\RuntimeException $e) {\n    throw new ConfigException('Bad index option: ' . $e->getMessage(), 0, $e);\n}","preventionTips":["Remember the exact whitelist: columns, type, name, length, order, include, where, accessMethod","Use 'type' => 'unique' instead of a 'unique' key","Keep index definitions in version-controlled, tested schema files"],"tags":["schema","validation","php"],"backgroundTag":"invalid-enum-value","analyzedSha":"1128eba9b09f1946df684811350e26f2cef68fac","analyzedAt":"2026-09-12T12:07:00.388Z","contentChangedAt":"2026-09-12T12:07:00.388Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}