SACGF / SACGF/variantgrid

Auto detected bugs - library

Open
#1,451 2 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Python
Stars
30
Forks
3
Avg merge
9h 28m
Merged PRs (30d)
42

Description

# Library App — Bug Report

## BUG 1: Formats the `datetime` class instead of the instance value [HIGH]

**File:** `library/preview_request.py` ~line 61

```python
return f"{datetime:%Y-%m-%d}" # BUG: formats the class object, not self.value
```

`datetime` here refers to the imported `datetime` class, not a datetime instance. Formatting a class with `%Y-%m-%d` will raise `TypeError` at runtime (or silently return garbage depending on Python version).

**Fix:**

```python
return f"{self.value:%Y-%m-%d}"
```

---

## BUG 2: `time_since()` subtracts float from datetime — always raises TypeError [HIGH]

**File:** `library/utils/date_utils.py` ~lines 10–12

```python
def time_since(start: datetime) -> timedelta:
end = time.time() # returns float (Unix timestamp)
return end - start # BUG: float - datetime raises TypeError
```

`time.time()` returns a `float`. Subtracting a `datetime` object from a `float` raises `TypeError: unsupported operand type(s) for -: 'float' and 'datetime.datetime'`. This function is completely broken.

**Fix:**

```python
def time_since(start: datetime) -> timedelta:
return datetime.now() - start
```

---

## BUG 3: `hash()` of a generator hashes by object identity, not content [HIGH]

**File:** `library/preview_request.py` ~line 332

```python
return hash((f for f in fields if f is not None))
```

`hash()` of a generator expression hashes the generator *object*, not its contents. Every call creates a new generator object, so every call returns a different hash value. This completely breaks any caching or equality logic relying on this hash.

**Fix:** Materialize the generator into a tuple first:

```python
return hash(tuple(f for f in fields if f is not None))
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.