Fix album token refresh handling and stabilize album lyrics flow#1
Fix album token refresh handling and stabilize album lyrics flow#1spacegrey23 wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e2fbcacfd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return res.status(404).send( | ||
| { | ||
| ...albumData || null, | ||
| status: 404, |
There was a problem hiding this comment.
Avoid spreading null in album error handler
If an exception occurs before albumData is assigned (e.g., a Spotify API/network error in getAlbumTracks), the catch falls through to the 404 response and spreads albumData || null. Spreading null/undefined throws a TypeError, so the error handler itself fails and the request ends up as an unhandled 500 instead of a clean error response. This path is reachable whenever the try block throws before albumData is set; consider guarding with albumData ? { ...albumData } : {} or similar.
Useful? React with 👍 / 👎.
Motivation
Description
currentAccessTokeninbackend/api/spotify/getAlbumTracks.mjsand return a structured 500 response when the token remains missing.backend/api/getAlbumLyrics.mjswhich iterates album tracks and attempts to collect lyrics viagetLyricsBySignature,getLyricsByQuery, andgetLyricsFromSpotify.GET /getAlbumDatainbackend/api/routes/routes.mjsand add album detection toclient/src/features/lyrics/useLyrics.jsandclient/src/hooks/useLyrics.jsto route requests to the correct endpoint.client/src/App.jsxto detect album responses and render a list of per-trackLyricsCardcomponents, and addbackend/test/spotify.test.mjsforparseAlbumId.Testing
node --test backend/test/spotify.test.mjs.parseAlbumIdforopen.spotify.comandspotify:album:formats and an invalid URL case.Codex Task