SACGF / SACGF/variantgrid

Auto-detected bugs - Classifications - hard ones

Open
#1,466 2 comments 0 reactions 1 assignee Claimed by @TheMadBug View on GitHub
bug
Dominant language
Python
Stars
30
Forks
3
Avg merge
9h 28m
Merged PRs (30d)
42

Description

Split from #1446 these are not obvious and need thought

--------------------------------------------------------------------------------

BUG 5 — is_pending always returns True (type mismatch comparison)
FILE: classification/views/discordance_report_views.py
LINE: 102
IMPACT: HIGH — pending-change indicator is always True, breaking the
discordance report UI's pending change display

```
@dataclass(frozen=True)
class _LabClinSig:
lab_clin_sig_key: _LabClinSigKey # a frozen dataclass
count: int
pending_clin_sig: Optional[str] = None # a string or None

@property
def is_pending(self) -> bool:
return self.lab_clin_sig_key != self.pending_clin_sig # BUG
```

A _LabClinSigKey object will never equal an Optional[str], so this property
always returns True regardless of whether there is actually a pending change.

Likely intended comparison (checking if a pending change to a *different*
classification exists):
return self.pending_clin_sig is not None and self.pending_clin_sig != self.clin_sig

Two plausible fixes:
- return self.pending_clin_sig is not None — "there is any pending change at all"
- return self.pending_clin_sig is not None and self.pending_clin_sig != self.clin_sig — "pending change targets a different classification"

Note: is_pending is currently never called anywhere (not in templates, not in Python). The template accesses pending_clin_sig directly. So this is dead code right now
— needs a decision on whether to fix it for future use or delete it.

--------------------------------------------------------------------------------

BUG 6 — "leave it as it was" comment but code overwrites the value
FILE: classification/views/discordance_report_views.py
LINES: 267–269
IMPACT: MEDIUM — when multiple pending clin-sig directions exist, the
suggested_pending_cs ends up as key.clin_sig (current value) instead
of remaining as the first-detected pending target

```
for pending_cs, pending_count in pendings.items():
total_count += pending_count
if suggested_pending_cs:
# can't handle pending in multiple directions, just leave it as it was
suggested_pending_cs = key.clin_sig # <-- BUG: overwrites, not "leaves"
else:
suggested_pending_cs = pending_cs
```

The comment says "leave it as it was" but the code replaces suggested_pending_cs
with key.clin_sig (the *current* clin sig, not the already-set pending target).
Should be `pass` (do nothing) to actually leave the variable unchanged.

Three plausible fixes when multiple pending directions are found:
- pass — keeps the first pending direction found (matches the comment literally)
- suggested_pending_cs = None — clears it to signal "ambiguous, show no pre-selection in the dropdown"
- suggested_pending_cs = key.clin_sig — current behaviour, pre-selects the current value (no change) in the dropdown

The comment says "leave it as it was" implying pass, but None might be better UX (the dropdown shows no pre-selection rather than silently favouring the first one
found). This depends on what the discordance action UI should show when labs have conflicting pending directions.

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.