Skip to content

Commit 6bb2245

Browse files
fix: PARSE_ERROR 500 on stats/export; tighten CLI and state tests
1 parent 0cd165f commit 6bb2245

5 files changed

Lines changed: 26 additions & 10 deletions

File tree

api/export_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def export_session(project_name, session_id):
293293
return error_response(
294294
ErrorCode.PARSE_ERROR,
295295
"Failed to parse session",
296-
400,
296+
500,
297297
)
298298

299299
rules = current_app.config.get("EXCLUSION_RULES") or []

api/sessions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_session_stats(project_name, session_id):
6969
return error_response(
7070
ErrorCode.PARSE_ERROR,
7171
"Failed to parse session",
72-
400,
72+
500,
7373
)
7474

7575
try:

static/js/shared/state.test.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import { describe, it, expect, afterEach } from 'vitest';
1+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
22
import { state } from './state.js';
33

4+
function resetState() {
5+
state.currentProject = null;
6+
state.cachedSessions = [];
7+
state.projectDisplayNames = {};
8+
state.navInProgress = false;
9+
}
10+
411
describe('state', () => {
12+
beforeEach(() => {
13+
resetState();
14+
});
15+
516
afterEach(() => {
6-
state.currentProject = null;
7-
state.cachedSessions = [];
8-
state.projectDisplayNames = {};
9-
state.navInProgress = false;
17+
resetState();
1018
});
1119

1220
it('initializes with null current project', () => {

tests/test_cli_e2e.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,19 @@ def test_cli_stats_exits_zero(tmp_path):
6666
assert proc.returncode == 0
6767

6868

69-
def test_cli_invalid_since_exits_nonzero():
70-
proc = _run_cli(["--since", "yesterday"])
69+
def test_cli_invalid_since_exits_nonzero(tmp_path):
70+
base = _seed_base_dir(tmp_path)
71+
proc = _run_cli([
72+
"export",
73+
"--since",
74+
"yesterday",
75+
"--base-dir",
76+
str(base),
77+
])
7178
assert proc.returncode != 0
7279
assert "--since" in proc.stderr
7380
assert "invalid choice" in proc.stderr.lower()
81+
assert "export" in proc.stderr
7482

7583

7684
def test_cli_export_creates_output(tmp_path):

tests/test_error_propagation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _boom(*args, **kwargs):
154154
monkeypatch.setattr("api.sessions.parse_session", _boom)
155155

156156
resp = client.get("/api/sessions/proj/abc/stats")
157-
assert resp.status_code == 400
157+
assert resp.status_code == 500
158158
body = resp.get_json()
159159
assert body.get("error") == "Failed to parse session"
160160
assert body.get("code") == "PARSE_ERROR"

0 commit comments

Comments
 (0)