cocoindex-io/cocoindex · error · ValueError
Unsupported field type: {field_def.type!r}
Error message
Unsupported field type: {field_def.type!r} What it means
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.
Source
Thrown at python/cocoindex/connectors/valkey/_target.py:534
attributes=attributes,
)
all_fields: list[Field] = [vector_field]
for field_def in schema.fields:
if field_def.type == "text":
all_fields.append(
TextField(name=field_def.name, sortable=field_def.sortable)
)
elif field_def.type == "tag":
all_fields.append(
TagField(name=field_def.name, sortable=field_def.sortable)
)
elif field_def.type == "numeric":
all_fields.append(
NumericField(name=field_def.name, sortable=field_def.sortable)
)
else:
raise ValueError(f"Unsupported field type: {field_def.type!r}")
prefix = _make_prefix(index_name)
options = FtCreateOptions(data_type=DataType.HASH, prefixes=[prefix])
await ft.create(client, index_name, schema=all_fields, options=options)
def reconcile(
self,
key: coco.StableKey,
desired_state: _IndexSpec | coco.NonExistenceType,
prev_possible_records: Collection[_IndexTrackingRecord],
prev_may_be_missing: bool,
/,
) -> (
coco.TargetReconcileOutput[_IndexAction, _IndexTrackingRecord, _DocumentHandler]
| None
):
if not isinstance(key, tuple) or len(key) != 2:View on GitHub (pinned to e84aa99b32)
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.
Example fix
// before FieldDef(name="category", type="keyword", sortable=False) // after FieldDef(name="category", type="text", sortable=False)
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"text", "numeric"}
bad = [f.name for f in field_defs if f.type not in SUPPORTED]
assert not bad, f"Unsupported Valkey field types: {bad}" Try / catch
try:
await component.reconcile(...)
except ValueError as e:
if "Unsupported field type" in str(e):
raise ConfigError("Use only 'text'/'numeric' field types (vectors go via VectorDef)") from e
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported record type: {self.record_type}
- Primary key column '{pk}' not found in columns: {list(self.c
- build_node_index_create requires at least one field
- VectorSchemaProvider is required for NumPy ndarray type.
- primary_key {primary_key!r} not found in columns ({sorted(co
AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08).
Data as JSON: /api/errors/2e2660f69c269e85.
Report an issue: GitHub.