fix: prevent 404 on /api/session/compress/status during session switch - #2185
1 commit merged into
Conversation
|
Reading Backend (
|
Two-part fix: - Backend: handle_get returns True (not None from j()) for compress/status route, preventing edge-case 404 fallback in do_GET - Frontend: resumeManualCompressionForSession silently returns on 404 instead of showing "Compression failed: not found" toast Includes 6 regression tests covering backend return value, idle/empty session responses, and frontend 404 guard presence.
759c263 to
9e45de4
Compare
|
Updated: broadened the frontend guard to also cover 5xx and network failures ( if(e&&(!e.status||e.status===404||e.status>=500)) return;Agreed on the audit pass for other |
f5be6e3
fix: prevent 404 on /api/session/compress/status during session switch (jasonjcwu)
fix: prevent 404 on /api/session/compress/status during session switch (jasonjcwu)
fix: prevent 404 on /api/session/compress/status during session switch (jasonjcwu)
Problem
Switching sessions in the sidebar triggers
resumeManualCompressionForSession(), which callsGET /api/session/compress/statusto check for active compression jobs. When no job is running (the common case), the route handler returnedNone(fromj()) instead ofTrue. In edge cases (stale process state, exception during response write), thedo_GETfallback produced{"error":"not found"}with HTTP 404. The frontend then showed a "Compression failed: not found" toast on every session switch.Fix
Backend (
api/routes.py):handle_getnow explicitly returnsTrueafter calling_handle_session_compress_status, ensuring theif result is False404-fallback indo_GETcan never trigger for this route.Frontend (
static/commands.js):resumeManualCompressionForSessioncatches 404 silently — no compression job means no error to surface. The earlyreturnin the catch block prevents theCompression failedtoast.Tests
6 regression tests in
tests/test_compress_status_404_fix.py:test_compress_status_returns_200_idle_for_unknown_sessiontest_compress_status_returns_200_idle_for_empty_session_idtest_handle_get_returns_true_for_compress_statushandle_getreturnsTrue(notNone)test_handle_get_returns_true_for_compress_status_no_sidtest_frontend_resume_404_silente.status===404guard with early returntest_frontend_compress_status_call_present