Fix: handle missing shows gracefully instead of crashing#256
Open
jakebromberg wants to merge 1 commit intomainfrom
Open
Fix: handle missing shows gracefully instead of crashing#256jakebromberg wants to merge 1 commit intomainfrom
jakebromberg wants to merge 1 commit intomainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getLatestShow()now returnsShow | undefinedinstead of assuming shows always existgetDJsInCurrentShow()returns[]instead of crashing when no shows existgetOnAirStatusForDJ()returnsfalseinstead of crashingactiveShowmiddleware returns 400 "No active show" instead of crashingGET /flowsheet/latestreturns200 nullinstead of404when flowsheet is emptyTest plan
getLatestnow expects 200 null instead of 404npm run typecheckcleanCloses #255