cocoindex-io/cocoindex · error

build_relationship_index_drop requires at least one field

Error message

build_relationship_index_drop requires at least one field

What it means

Input guard in the FalkorDB Cypher builder mirroring its create counterpart: DROP INDEX requires at least one indexed property, and an empty fields list would yield invalid Cypher. Fired when the connector tears down or rebuilds a relationship index but the stored/declared field list is empty. Provide at least one field when declaring the relationship index.

Solutions

  1. Pass exactly the fields the relationship index was created with.
  2. Guard the drop call: only issue it when recorded fields are non-empty.
  3. Fix the metadata source so relationship index fields survive across runs.

Example fix

// before
build_relationship_index_drop(rel_type="WORKS_AT", fields=[])
// after
build_relationship_index_drop(rel_type="WORKS_AT", fields=["since"])
Defensive patterns

Strategy: validation

Validate before calling

if fields:
    cypher = build_relationship_index_drop(rel_type, fields)
# else: nothing to drop

Type guard

def droppable(fields: object) -> bool:
    return isinstance(fields, (list, tuple)) and len(fields) > 0

Try / catch

try:
    cypher = build_relationship_index_drop(rel_type, fields)
except ValueError as e:
    logger.warning('no fields recorded for relationship index %s; skipping drop: %s', rel_type, e)
    cypher = None

Prevention

When it happens

Trigger: Calling build_relationship_index_drop(rel_type, fields=[]) — dropping a relationship index whose field list is empty or lost.

Common situations: Teardown/cleanup passing empty fields; index metadata not persisted so the drop spec is empty; mismatch between create and drop field lists.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at python/cocoindex/connectors/falkordb/_cypher.py:169

    """``DROP INDEX FOR (e:`Label`) ON (e.`f1`, ...)``."""
    if not fields:
        raise ValueError("build_node_index_drop requires at least one field")
    field_list = ", ".join(f"e.{_quote(f)}" for f in fields)
    return f"DROP INDEX FOR (e:{_quote(label)}) ON ({field_list})"


def build_relationship_index_create(rel_type: str, fields: Sequence[str]) -> str:
    """``CREATE INDEX FOR ()-[e:`RelType`]-() ON (e.`f1`, ...)``."""
    if not fields:
        raise ValueError("build_relationship_index_create requires at least one field")
    field_list = ", ".join(f"e.{_quote(f)}" for f in fields)
    return f"CREATE INDEX FOR ()-[e:{_quote(rel_type)}]-() ON ({field_list})"


def build_relationship_index_drop(rel_type: str, fields: Sequence[str]) -> str:
    """``DROP INDEX FOR ()-[e:`RelType`]-() ON (e.`f1`, ...)``."""
    if not fields:
        raise ValueError("build_relationship_index_drop requires at least one field")
    field_list = ", ".join(f"e.{_quote(f)}" for f in fields)
    return f"DROP INDEX FOR ()-[e:{_quote(rel_type)}]-() ON ({field_list})"


def build_vector_index_create(
    label: str,
    field: str,
    dimension: int,
    metric: str,
) -> str:
    """``CREATE VECTOR INDEX FOR (e:`Label`) ON (e.`field`) OPTIONS {...}``.

    ``metric`` is the FalkorDB-side ``similarityFunction`` value
    (e.g. ``"cosine"``, ``"euclidean"``). Caller is responsible for translating
    user-facing names into the FalkorDB vocabulary before invoking.
    """
    if dimension <= 0:
        raise ValueError(f"Invalid vector dimension: {dimension}")

View on GitHub (pinned to e84aa99b32)