{"record":{"id":"2e2660f69c269e85","repo":"cocoindex-io/cocoindex","slug":"unsupported-field-type-field-def-type-r","errorCode":null,"errorMessage":"Unsupported field type: {field_def.type!r}","messagePattern":"Unsupported field type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/valkey/_target.py","lineNumber":534,"sourceCode":"            attributes=attributes,\n        )\n\n        all_fields: list[Field] = [vector_field]\n        for field_def in schema.fields:\n            if field_def.type == \"text\":\n                all_fields.append(\n                    TextField(name=field_def.name, sortable=field_def.sortable)\n                )\n            elif field_def.type == \"tag\":\n                all_fields.append(\n                    TagField(name=field_def.name, sortable=field_def.sortable)\n                )\n            elif field_def.type == \"numeric\":\n                all_fields.append(\n                    NumericField(name=field_def.name, sortable=field_def.sortable)\n                )\n            else:\n                raise ValueError(f\"Unsupported field type: {field_def.type!r}\")\n\n        prefix = _make_prefix(index_name)\n        options = FtCreateOptions(data_type=DataType.HASH, prefixes=[prefix])\n\n        await ft.create(client, index_name, schema=all_fields, options=options)\n\n    def reconcile(\n        self,\n        key: coco.StableKey,\n        desired_state: _IndexSpec | coco.NonExistenceType,\n        prev_possible_records: Collection[_IndexTrackingRecord],\n        prev_may_be_missing: bool,\n        /,\n    ) -> (\n        coco.TargetReconcileOutput[_IndexAction, _IndexTrackingRecord, _DocumentHandler]\n        | None\n    ):\n        if not isinstance(key, tuple) or len(key) != 2:","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/valkey/_target.py#L516-L552","documentation":"When creating the Valkey search index, `_create_index` maps each declared field definition's type to a Valkey FT schema field class: 'text' → TextField, 'numeric' → NumericField, etc. A `field_def.type` outside the supported set (e.g. 'vector' handled elsewhere, or an unrecognized string like 'string' or 'keyword') falls into the else branch and raises this ValueError.","triggerScenarios":"Building an index whose field defs include a type string not among the handled cases in `_create_index` — e.g. a field_def with type=\"keyword\" or a typo like \"nmeric\" — during `_apply_actions` when the index is first created.","commonSituations":"Hand-writing FieldDef lists with Redis-style type names ('keyword', 'boolean') that Valkey's FT.CREATE mapping in this connector doesn't support; typos in type strings; schema drift after the connector added new supported types.","solutions":["Change field_def.type to a supported value ('text' or 'numeric', per the mapping in _create_index; vector fields go through the vector-def path, not this list).","Fix typos in type strings by matching the exact literals used in the connector's _create_index implementation.","If you need a type that isn't supported (e.g. tag/boolean), store it as 'text' or 'numeric', or file/patch support for that field type in the connector."],"exampleFix":"// before\nFieldDef(name=\"category\", type=\"keyword\", sortable=False)\n\n// after\nFieldDef(name=\"category\", type=\"text\", sortable=False)","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"text\", \"numeric\"}\nbad = [f.name for f in field_defs if f.type not in SUPPORTED]\nassert not bad, f\"Unsupported Valkey field types: {bad}\"","typeGuard":null,"tryCatchPattern":"try:\n    await component.reconcile(...)\nexcept ValueError as e:\n    if \"Unsupported field type\" in str(e):\n        raise ConfigError(\"Use only 'text'/'numeric' field types (vectors go via VectorDef)\") from e\n    raise","preventionTips":["Use only the type literals supported by _create_index ('text', 'numeric'); vectors are declared separately","Don't copy Redis field type names ('keyword', 'tag', 'boolean') into Valkey FieldDefs","Cover index creation in a test so unsupported types fail in CI before deployment"],"tags":["python","schema","index","valkey"],"backgroundTag":"unsupported-enum-value","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"}