Skip to content

Fix: handle missing shows gracefully instead of crashing#256

Open
jakebromberg wants to merge 1 commit intomainfrom
bugfix/no-show-errors
Open

Fix: handle missing shows gracefully instead of crashing#256
jakebromberg wants to merge 1 commit intomainfrom
bugfix/no-show-errors

Conversation

@jakebromberg
Copy link
Member

Summary

  • getLatestShow() now returns Show | undefined instead of assuming shows always exist
  • getDJsInCurrentShow() returns [] instead of crashing when no shows exist
  • getOnAirStatusForDJ() returns false instead of crashing
  • activeShow middleware returns 400 "No active show" instead of crashing
  • GET /flowsheet/latest returns 200 null instead of 404 when flowsheet is empty

Test plan

  • 3 new unit tests for no-show edge cases (getLatestShow, getDJsInCurrentShow, getOnAirStatusForDJ)
  • Updated existing test: getLatest now expects 200 null instead of 404
  • npm run typecheck clean
  • 320/320 tests pass

Closes #255

getLatestShow() returns undefined when no shows exist in the database, which caused three problems:

- GET /djs/djs-on-air crashed with "Cannot read properties of undefined (reading 'end_time')" because getDJsInCurrentShow and getOnAirStatusForDJ accessed .end_time on the undefined result without a null check
- GET /flowsheet/latest returned 404 instead of 200 with null when the flowsheet was empty, causing unnecessary error noise in the frontend console
- The activeShow middleware crashed on the same undefined .end_time access

All three callers now check for undefined before accessing show properties. The return type of getLatestShow is updated to Show | undefined to make this explicit at the type level.
@jakebromberg jakebromberg requested a review from AyBruno March 26, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server crashes when no shows exist in database

1 participant