infiniflow / infiniflow/infinity

[Bug]: IndexInfo equality and hashing are broken (AttributeError on ==, TypeError on hash)

Open Beginner friendly
#3,446 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
4.7k
Forks
445
Avg merge
2d 2h
Merged PRs (30d)
7

Description

### Is there an existing issue for the same bug?

- [x] I have checked the existing issues.

### Version or Commit ID

main @ 4954148 (current main as of 2026-09-08)

### Other environment information

```Markdown

```

### Actual behavior and How to reproduce it

IndexInfo (the object list_indexes/show_index returns and create_index accepts) has two broken dunder methods in the shipped Python packages:

1. Embedded SDK (python/infinity_embedded/index.py): __eq__ reads other.index_name, an attribute that does not exist - the field is column_name. ANY == comparison between two IndexInfo objects raises:

AttributeError: 'IndexInfo' object has no attribute 'index_name'

2. Both the client SDK (python/infinity_sdk/infinity/index.py) and the embedded SDK: __hash__ puts the params dict straight into the hash tuple, so hashing any IndexInfo created with init params (the normal case - e.g. HNSW with M/ef) raises:

TypeError: unhashable type: 'dict'

So IndexInfo objects cannot be compared in the embedded SDK, and cannot be deduplicated or used as set members / dict keys anywhere.

Repro (no server needed):

from infinity.index import IndexInfo, IndexType
a = IndexInfo("c1", IndexType.Hnsw, {"M": "16"})
b = IndexInfo("c1", IndexType.Hnsw, {"M": "16"})
print(a == b) # embedded SDK: AttributeError
print(hash(a)) # both packages: TypeError: unhashable type: 'dict'

### Expected behavior

a == b is True for equal IndexInfo objects, False for different ones, and hash() works so IndexInfo can live in sets/dicts. __eq__ and __hash__ stay consistent (params compared/hashed as a sorted item tuple, insensitive to dict ordering).

### Additional information

Fix: correct the attribute name in the embedded __eq__, and hash params as tuple(sorted(params.items())) in both packages. PR with a serverless regression test (test_index_info_eq_and_hash in python/test_pysdk/test_index.py) coming.

Contributor guide

Open the contributing guide

Research direction

Start by reading IndexInfo in python/infinity_embedded/index.py and python/infinity_sdk/infinity/index.py, then inspect test_index_info_eq_and_hash in python/test_pysdk/test_index.py. Run the serverless regression test first. Done means equal objects compare successfully, hashes work for parameterized indexes, and parameter dictionary ordering does not affect equality or hashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.