cocoindex-io/cocoindex · error · ValueError

Unsupported LanceDB vector index type: {spec.index_type!r}.

Error message

Unsupported LanceDB vector index type: {spec.index_type!r}. Supported types are 'ivf_pq' and 'hnsw_pq'.

What it means

When applying declared index actions, the vector index spec's index_type must be one of the supported LanceDB index configs: 'ivf_pq' or 'hnsw_pq'. Any other string has no corresponding lancedb.index config class, so a ValueError lists the supported values.

Source

Thrown at python/cocoindex/connectors/lancedb/_target.py:786

                        index_config_kwargs["num_partitions"] = spec.num_partitions
                    if spec.num_sub_vectors is not None:
                        index_config_kwargs["num_sub_vectors"] = spec.num_sub_vectors
                    if spec.num_bits is not None:
                        index_config_kwargs["num_bits"] = spec.num_bits
                    index_config = lancedb_index.IvfPq(**index_config_kwargs)
                elif spec.index_type == "hnsw_pq":
                    index_config_kwargs = {"distance_type": spec.metric}
                    if spec.m is not None:
                        index_config_kwargs["m"] = spec.m
                    if spec.ef_construction is not None:
                        index_config_kwargs["ef_construction"] = spec.ef_construction
                    if spec.num_sub_vectors is not None:
                        index_config_kwargs["num_sub_vectors"] = spec.num_sub_vectors
                    if spec.num_bits is not None:
                        index_config_kwargs["num_bits"] = spec.num_bits
                    index_config = lancedb_index.HnswPq(**index_config_kwargs)
                else:
                    raise ValueError(
                        f"Unsupported LanceDB vector index type: {spec.index_type!r}. "
                        "Supported types are 'ivf_pq' and 'hnsw_pq'."
                    )
                await table.create_index(
                    spec.column,
                    config=index_config,
                    replace=True,
                    name=action.name,
                )

    def reconcile(
        self,
        key: coco.StableKey,
        desired_state: _VectorIndexSpec | coco.NonExistenceType,
        prev_possible_records: Collection[_VectorIndexFingerprint],
        prev_may_be_missing: bool,
        /,
    ) -> coco.TargetReconcileOutput[_VectorIndexAction, _VectorIndexFingerprint] | None:

View on GitHub (pinned to e84aa99b32)

Solutions

  1. Change the index spec to index_type="ivf_pq" or "hnsw_pq".
  2. Fix casing — the comparison is against lowercase literal names.
  3. If you need another LanceDB index type, check the connector version/docs for support rather than guessing a name.

Example fix

// before
VectorIndexSpec(column="embedding", index_type="ivf_flat", ...)
// after
VectorIndexSpec(column="embedding", index_type="ivf_pq", ...)
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = {"ivf_pq", "hnsw_pq"}
assert spec.index_type in SUPPORTED, f"index_type must be one of {SUPPORTED}, got {spec.index_type!r}"

Try / catch

try:
    await app.update()
except ValueError as e:
    if "Unsupported LanceDB vector index type" in str(e):
        ...  # fix spec.index_type to 'ivf_pq' or 'hnsw_pq'
    raise

Prevention

When it happens

Trigger: Declaring a vector index with `index_type` set to something else (e.g. 'ivf_flat', 'btree', 'HNSW', or a typo) so that _apply_actions falls through both known branches.

Common situations: Copying index type names from LanceDB docs that include variants CocoIndex doesn't expose; case mismatch ('IVF_PQ'); older/newer naming from other vector stores.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08). Data as JSON: /api/errors/cb0a3fa95ecccd89. Report an issue: GitHub.