gchq / gchq/ConcourseTools

Version equality uses hashes instead of version data

Open Beginner friendly
#49 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
17
Forks
3
Avg merge
22h 1m
Merged PRs (30d)
3

Description

## Reproduction

Reproduced on `main` at `1b70bf6c9d988fb200ae506676ad1e8f5f1b644a`.

```python
from concoursetools import Version

class FileVersion(Version):
def __init__(self, path):
self.path = path

def __hash__(self):
return 42 # Force a collision for a deterministic reproduction

first, second = FileVersion("one"), FileVersion("two")
print(first == second) # True, despite different version data
print(first == 42) # True, but an integer is not a version
print(first == []) # TypeError: unhashable type: 'list'
```

`Version.__eq__` compares only hashes. Two different versions with the same hash also compare equal, so a set or dictionary can discard a distinct version. This can be reproduced deterministically with a `FileVersion` subclass whose `__hash__` returns a constant.

## Expected

Equality should compare the version type and flattened version data. Unrelated objects should be handled through `NotImplemented`, without attempting to hash them.

I have reproduced this and am preparing a focused fix with regression tests.

Contributor guide

Open the contributing guide

Research direction

Start by inspecting Version.__eq__ and the Version data-flattening behavior described in the reproduction. Add regression tests covering hash collisions, unrelated objects, and unhashable objects; done means equality uses version type and flattened data without hashing unrelated values.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.