{"record":{"id":"57e56d259006c181","repo":"cocoindex-io/cocoindex","slug":"invalid-vector-dimension-dimension-57e56d","errorCode":null,"errorMessage":"Invalid vector dimension: {dimension}","messagePattern":"Invalid vector dimension: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/falkordb/_target.py","lineNumber":1310,"sourceCode":"            return dict(row)\n        record_info = RecordType(type(row))\n        return {f.name: getattr(row, f.name) for f in record_info.fields}\n\n    def declare_vector_index(\n        self: TableTarget[RowT],\n        *,\n        name: str | None = None,\n        field: str,\n        metric: Literal[\"cosine\", \"euclidean\", \"ip\"] = \"cosine\",\n        dimension: int,\n    ) -> None:\n        \"\"\"Declare a vector index on a column of this table.\"\"\"\n        _validate_identifier(field, \"vector index field\")\n        if name is None:\n            name = f\"idx_{self._table_name}__{field}\"\n        _validate_identifier(name, \"vector index name\")\n        if dimension <= 0:\n            raise ValueError(f\"Invalid vector dimension: {dimension}\")\n        spec = _VectorIndexSpec(field=field, metric=metric, dimension=dimension)\n        att_provider = self._provider.attachment(\"vector_index\")\n        coco.declare_target_state(att_provider.target_state(name, spec))\n\n    def __coco_memo_key__(self) -> str:\n        return self._provider.memo_key\n\n\n# ---------------------------------------------------------------------------\n# RelationTarget\n# ---------------------------------------------------------------------------\n\n\nclass RelationTarget(\n    Generic[RowT, coco.MaybePendingS], coco.ResolvesTo[\"RelationTarget[RowT]\"]\n):\n    \"\"\"A target for writing relation records (edges) to a FalkorDB relationship type.\"\"\"\n","sourceCodeStart":1292,"sourceCodeEnd":1328,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/falkordb/_target.py#L1292-L1328","documentation":"`TableTarget.declare_vector_index` validates the `dimension` argument before declaring the index target state. FalkorDB vector indexes require a positive dimension; a zero or negative value would create an invalid index spec, so ValueError is raised.","triggerScenarios":"Calling `target.declare_vector_index(field=\"embedding\", dimension=0)` or a negative/derived-zero dimension — e.g. dimension read from an unset config or `len` of an empty list.","commonSituations":"Dimension computed from a model config that failed to load; placeholder 0 left in test code (as in the test that exercises this path); mismatch between the vector column's schema dimension and the index dimension.","solutions":["Pass the actual embedding dimension, e.g. `declare_vector_index(field=\"embedding\", metric=\"cosine\", dimension=384)`.","Match the dimension to the column's `VectorSchemaProvider(dimension=...)` value.","Assert `dim > 0` before calling when the value is computed."],"exampleFix":"// before\ntarget.declare_vector_index(field=\"embedding\", dimension=dim)  # dim == 0\n// after\nassert dim > 0\ntarget.declare_vector_index(field=\"embedding\", dimension=dim)","handlingStrategy":"validation","validationCode":"assert dimension > 0, f\"vector index dimension must be positive, got {dimension}\"\ntarget.declare_vector_index(field=\"embedding\", metric=\"cosine\", dimension=dimension)","typeGuard":null,"tryCatchPattern":"try:\n    target.declare_vector_index(field=\"embedding\", dimension=dim)\nexcept ValueError as e:\n    if \"Invalid vector dimension\" in str(e):\n        logging.error(\"Fix dimension source (config/model metadata): %s\", e)\n    raise","preventionTips":["Reuse the same dimension constant as the column's VectorSchemaProvider.","Validate dimension at config load time.","Avoid placeholder 0/negative values in code; use None + explicit fill."],"tags":["python","falkordb","vector-index","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}