Add regression for failed sloppak websocket load - #17
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a regression test and a server-side guard to ensure the highway WebSocket fails cleanly when a sloppak/feedpak load returns None, preventing a loaded_slop.song dereference crash and verifying the client sees a clear failure.
Changes:
- Add an explicit early-return guard in
highway_wswhensloppak_mod.load_song(...)returnsNone. - Add a new pytest regression covering the failed sloppak load path (accept → error message → close).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/routers/ws_highway.py |
Adds a guard to send {"error": "Failed to load sloppak"} and close the socket when the sloppak loader returns None. |
tests/test_highway_ws_failed_sloppak_load.py |
New regression test that simulates load_song returning None and asserts error emission + socket close. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Carolina <79524656+carochacs@users.noreply.github.com>
📝 WalkthroughWalkthroughThe highway WebSocket handler now handles failed sloppak loads by stopping keepalive notifications, sending an error, closing the connection, and returning. A regression test verifies the response and confirms that stems remain unchanged. ChangesHighway WebSocket sloppak failure
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 20 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (20 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_highway_ws_failed_sloppak_load.py`:
- Around line 10-27: Strengthen the test using _CapturingWS by recording close
calls and asserting the handler terminates immediately after the sloppak load
error. Verify the exact two-frame message sequence and the expected close
behavior, so a handler that sends the error and continues processing fails the
test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7640adb5-2b17-4f03-a584-024f666bc7c1
📒 Files selected for processing (2)
lib/routers/ws_highway.pytests/test_highway_ws_failed_sloppak_load.py
- test_highway_ws_failed_sloppak_load.py: assert the exact two-frame message sequence and a single close() call, not just that the error was somewhere in the messages list — a handler that sends the error and keeps processing would previously still pass (CodeRabbit). - CHANGELOG.md: add the [Unreleased] Fixed entry for this bug, per the PR template checklist.
What
Follow-up to #16. That fix guarded the later stem-access branch against a
Noneloaded_slop, but the highway websocket handler still dereferencedloaded_slop.songimmediately after the sloppak load — before the stem branch is ever reached. A failed load (cache corruption, partial extraction, etc.) still crashed the connection instead of reporting the failure.sloppak_mod.load_song(...)returns, beforesong = loaded_slop.songis dereferenced.Noneresult: cancels the keepalive task, sends{"error": "Failed to load sloppak"}, closes the socket, and returns — matching the existing failure-reporting pattern used elsewhere in this handler.loading→error), a singleclose()call, and that the handler never reaches stem access.feedpak surface
Checklist
CHANGELOG.md[Unreleased]updated (user-visible changes)git commit -s) — not on all commits; this PR targets this fork's ownmain, notgot-feedback/feedBackupstreamNotes
convert_wemis called directly (not viarun_in_executor) inside this same async handler at two pre-existing call sites (lines 468, 490) — flagged by CodeRabbit's automated checks. That's out of scope here: neither call site is touched by this PR's diff, and wrapping them is a separate, more invasive change than a load-failure regression test warrants.Validation
python -m pytest tests/test_highway_ws_failed_sloppak_load.py -v— not run in this sandbox becausepytestis not installedgit diff --check— passes