Repository navigation
fix(cli): return an error instead of panicking on empty play results - #633
Conversation
A search with no hits stores an empty page, not None, so `play -n` indexed items[0] and panicked, and `play -u <empty playlist> -r` asked rand for a value in 0..0. Pull the lookup into first_result_uri, which uses first() and keeps the existing "no <type>s with name" and "has no id" errors, add random_offset, and treat an empty page like None in query. Fixes LargeModGames#603 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: LargeModGames/spotatui/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe CLI now returns errors when playback uses an empty search result or an empty playlist for random selection. Search commands return their existing no-results messages when a result page is empty. ChangesCLI empty-result handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The empty-result handling is mergeable after normal checks; no actionable issue remains identified. Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
The floors in |
Summary
Fixes #603.
playnow calls a purefirst_result_uri(&SearchResult, &Type, &str), which usesfirst()instead ofitems[0]. An empty page and aNonepage both return the existingno <type>s with name '...'error, and a hit without an id keeps its... has no iderror. Theapplock stays inside its own block.play_uriusesrandom_offset(total), which isNonefor 0. OnNoneit callshandle_error(anyhow!("playlist has no tracks"))and returns, like the fetch error branch.querytreats an empty page likeNonein all five arms, sospotatui searchwith no hits printsno tracks with name '...'instead of a blank line.println!/eprintln!added.Tests in
src/cli/cli_app.rscover the cases in the issue (empty track and playlist pages, first track and playlist hit,random_offset), plus empty and missing pages for albums, artists and shows, the type of each hit, and the missing-id errors.Testing
cargo fmt --all -- --check: cleancargo clippy --no-default-features --features telemetry,tui -- -D warnings: cleancargo test --no-default-features --features telemetry,tui: 1291 passed, 0 failedcargo test --no-default-features --features telemetry,tui cli_app: 11 passeditems[0]back in the track arm andrandom_range(0..total)back without the guard,play_by_name_reports_no_tracks_when_the_search_page_is_emptyanda_random_offset_into_an_empty_playlist_is_nonefail.Additional notes
I didn't run the CLI against a real account.
This is one of five small PRs I opened together (#602, #603, #594, #595, #599). Each changelog entry sits at a different spot in
[Unreleased]so they merge without conflicts in any order.Written with AI coding assistants: the fix was drafted by Codex, then extracted onto its own branch, checked against the issue and re-tested by Claude Code.
🤖 Generated with Claude Code
Summary by CodeRabbit