{"record":{"id":"90f0b07933b2f62b","repo":"cocoindex-io/cocoindex","slug":"build-node-index-drop-requires-at-least-one-field","errorCode":null,"errorMessage":"build_node_index_drop requires at least one field","messagePattern":"build_node_index_drop requires at least one field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/falkordb/_cypher.py","lineNumber":153,"sourceCode":"        )\n    return (\n        f\"MATCH ()-[r:{_quote(rel_type)} \"\n        f\"{_key_clause('key', pk_fields, 'r')}]->() DELETE r\"\n    )\n\n\ndef build_node_index_create(label: str, fields: Sequence[str]) -> str:\n    \"\"\"``CREATE INDEX FOR (e:`Label`) ON (e.`f1`, e.`f2`, ...)``.\"\"\"\n    if not fields:\n        raise ValueError(\"build_node_index_create requires at least one field\")\n    field_list = \", \".join(f\"e.{_quote(f)}\" for f in fields)\n    return f\"CREATE INDEX FOR (e:{_quote(label)}) ON ({field_list})\"\n\n\ndef build_node_index_drop(label: str, fields: Sequence[str]) -> str:\n    \"\"\"``DROP INDEX FOR (e:`Label`) ON (e.`f1`, ...)``.\"\"\"\n    if not fields:\n        raise ValueError(\"build_node_index_drop requires at least one field\")\n    field_list = \", \".join(f\"e.{_quote(f)}\" for f in fields)\n    return f\"DROP INDEX FOR (e:{_quote(label)}) ON ({field_list})\"\n\n\ndef build_relationship_index_create(rel_type: str, fields: Sequence[str]) -> str:\n    \"\"\"``CREATE INDEX FOR ()-[e:`RelType`]-() ON (e.`f1`, ...)``.\"\"\"\n    if not fields:\n        raise ValueError(\"build_relationship_index_create requires at least one field\")\n    field_list = \", \".join(f\"e.{_quote(f)}\" for f in fields)\n    return f\"CREATE INDEX FOR ()-[e:{_quote(rel_type)}]-() ON ({field_list})\"\n\n\ndef build_relationship_index_drop(rel_type: str, fields: Sequence[str]) -> str:\n    \"\"\"``DROP INDEX FOR ()-[e:`RelType`]-() ON (e.`f1`, ...)``.\"\"\"\n    if not fields:\n        raise ValueError(\"build_relationship_index_drop requires at least one field\")\n    field_list = \", \".join(f\"e.{_quote(f)}\" for f in fields)\n    return f\"DROP INDEX FOR ()-[e:{_quote(rel_type)}]-() ON ({field_list})\"","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/falkordb/_cypher.py#L135-L171","documentation":"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.","triggerScenarios":"Calling build_node_index_drop(label, fields=[]) — usually while dropping an index whose field spec was lost or never recorded.","commonSituations":"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.","solutions":["Pass exactly the same fields the index was created with.","Verify stored index metadata actually contains field names before issuing the drop.","Skip the drop call when there is no recorded index instead of passing an empty list."],"exampleFix":"// before\nbuild_node_index_drop(label=\"Person\", fields=[])\n// after\nbuild_node_index_drop(label=\"Person\", fields=[\"name\"])","handlingStrategy":"validation","validationCode":"if fields:\n    cypher = build_node_index_drop(label, fields)\n# else: nothing to drop","typeGuard":"def droppable(fields: object) -> bool:\n    return isinstance(fields, (list, tuple)) and len(fields) > 0","tryCatchPattern":"try:\n    cypher = build_node_index_drop(label, fields)\nexcept ValueError as e:\n    logger.warning('no index fields recorded for %s; skipping drop: %s', label, e)\n    cypher = None","preventionTips":["Persist the exact field list used at create time and reuse it at drop time.","Guard drop calls: skip when the recorded fields list is empty.","Keep create/drop specs in a single index-spec structure so they can't diverge."],"tags":["cypher","falkordb","index","delete"],"backgroundTag":"missing-required-argument","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"}