Skip to content

Commit 1749639

Browse files
Copilottedil
andauthored
fix(grzctl): handle empty submission states in TUI search results (#468)
Fixes #385 TUI crashes with `ValueError: max() iterable argument is empty` when displaying submissions that have no state updates yet. **Changes:** - Replace direct `max(submission.states, ...)` with existing `submission.get_latest_state()` method which returns `None` for empty states - Display "missing" (styled as italic yellow) for "Latest State" and "State Timestamp" columns when no states exist, matching the existing pattern used elsewhere in the TUI ```python # Before: crashes on empty states latest_state = max(submission.states, key=lambda st: st.timestamp) # After: graceful handling with styled "missing" text latest_state = submission.get_latest_state() self.add_row( submission.id, submission.pseudonym, latest_state.state if latest_state else rich.text.Text("missing", style="italic yellow"), latest_state.timestamp if latest_state else rich.text.Text("missing", style="italic yellow"), ) ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tedil <7976289+tedil@users.noreply.github.com>
1 parent 0bd31aa commit 1749639

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • packages/grzctl/src/grzctl/commands/db

packages/grzctl/src/grzctl/commands/db/tui.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,13 @@ async def search(
245245
submissions = session.exec(statement).all()
246246
logger.debug("Populating search table from the following statement: '%s'", str(statement))
247247
for submission in submissions:
248-
latest_state = max(submission.states, key=lambda st: st.timestamp)
249-
self.add_row(submission.id, submission.pseudonym, latest_state.state, latest_state.timestamp)
248+
latest_state = submission.get_latest_state()
249+
self.add_row(
250+
submission.id,
251+
submission.pseudonym,
252+
latest_state.state if latest_state else rich.text.Text("missing", style="italic yellow"),
253+
latest_state.timestamp if latest_state else rich.text.Text("missing", style="italic yellow"),
254+
)
250255

251256
self.loading = False
252257

0 commit comments

Comments
 (0)