cocoindex-io/cocoindex · error

build_node_index_drop requires at least one field

Error message

build_node_index_drop requires at least one field

What it means

Input guard in the FalkorDB Cypher builder. An index in FalkorDB is defined over at least one property; generating DROP INDEX ... ON () with an empty field list would produce syntactically invalid Cypher that the server rejects with a confusing parse error. This ValueError fires when a caller (e.g. the connector's index sync) passes an empty fields sequence for a node label index — typically a schema whose primary key/index fields were not resolved. Ensure the index declaration includes at least one field.

Source

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

        )
    return (
        f"MATCH ()-[r:{_quote(rel_type)} "
        f"{_key_clause('key', pk_fields, 'r')}]->() DELETE r"
    )


def build_node_index_create(label: str, fields: Sequence[str]) -> str:
    """``CREATE INDEX FOR (e:`Label`) ON (e.`f1`, e.`f2`, ...)``."""
    if not fields:
        raise ValueError("build_node_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(label)}) ON ({field_list})"


def build_node_index_drop(label: str, fields: Sequence[str]) -> str:
    """``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})"

View on GitHub (pinned to e84aa99b32)

Solutions

  1. Pass exactly the same fields the index was created with.
  2. Verify stored index metadata actually contains field names before issuing the drop.
  3. Skip the drop call when there is no recorded index instead of passing an empty list.

Example fix

// before
build_node_index_drop(label="Person", fields=[])
// after
build_node_index_drop(label="Person", fields=["name"])
Defensive patterns

Strategy: validation

Validate before calling

if fields:
    cypher = build_node_index_drop(label, 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_node_index_drop(label, fields)
except ValueError as e:
    logger.warning('no index fields recorded for %s; skipping drop: %s', label, e)
    cypher = None

Prevention

When it happens

Trigger: Calling build_node_index_drop(label, fields=[]) — usually while dropping an index whose field spec was lost or never recorded.

Common situations: Index cleanup at teardown passing an empty list; index spec loaded from state where fields were never persisted; symmetric mismatch with a create call that also had empty fields.

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/90f0b07933b2f62b. Report an issue: GitHub.