{"record":{"id":"320b87c511758110","repo":"cocoindex-io/cocoindex","slug":"build-node-index-create-requires-at-least-one-fiel","errorCode":null,"errorMessage":"build_node_index_create requires at least one field","messagePattern":"build_node_index_create requires at least one field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/falkordb/_cypher.py","lineNumber":145,"sourceCode":"    \"\"\"``MATCH ()-[r:`RelType` {pk: $key_0, ...}]->() DELETE r``.\n\n    Endpoints are intentionally not deleted — they're tracked by their own\n    table handlers and will be deleted by their own reconciler if orphaned.\n    \"\"\"\n    if not pk_fields:\n        raise ValueError(\n            \"build_relationship_delete requires at least one primary key field\"\n        )\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})\"","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/falkordb/_cypher.py#L127-L163","documentation":"build_node_index_create() requires at least one field because it emits CREATE INDEX ... ON (e.f1, ...) and an index over an empty field list is invalid Cypher. It fails fast rather than generating a query FalkorDB would reject.","triggerScenarios":"Calling build_node_index_create(label, fields=[]) — e.g. an index specification in the target schema lists a label but no properties.","commonSituations":"Index config defined as an empty list by default and never populated; fields filtered out because names didn't match schema columns; copy-pasted index declaration with fields left blank.","solutions":["Pass at least one property name in fields (typically a frequently filtered property).","If no index is actually needed, skip the index declaration entirely instead of passing an empty list.","Check why the fields list is empty upstream (config parsing or name filtering)."],"exampleFix":"// before\nbuild_node_index_create(label=\"Person\", fields=[])\n// after\nbuild_node_index_create(label=\"Person\", fields=[\"name\"])","handlingStrategy":"validation","validationCode":"if not fields:\n    raise ValueError('node index requires at least one field; skip the index instead')\ncypher = build_node_index_create(label, fields)","typeGuard":"def indexable(fields: object) -> bool:\n    return isinstance(fields, (list, tuple)) and len(fields) > 0 and all(isinstance(f, str) for f in fields)","tryCatchPattern":"try:\n    cypher = build_node_index_create(label, fields)\nexcept ValueError as e:\n    logger.warning('skipping index on %s: %s', label, e)\n    cypher = None","preventionTips":["Only declare an index when there is at least one property worth indexing; otherwise omit it entirely.","Validate index specs at config load: label present AND fields non-empty.","Ensure indexed field names match actual schema columns so filtering doesn't silently empty the list."],"tags":["cypher","falkordb","index","schema"],"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"}