Skip to content

Commit a6c3ae9

Browse files
committed
review: fail smoke on /api/workspaces parse error (CodeRabbit)
The WS_ID extraction was suppressing python3's stderr with `2>/dev/null` and treating a missing parse result the same as "no non-global workspace exists". So /api/workspaces returning 200 with malformed JSON would silently skip the three workspace-scoped probes and the script would still exit 0 — a false green. Wrapped the parse in `if ... ; then ... else fail=$((fail+1)); fi` so python3's non-zero exit (raised by json.load on bad input) routes through the FAIL printf, the workspace block is skipped explicitly, and the script exits non-zero with the rest of the failures. Happy path: 11/11 probes still pass.
1 parent 590dc21 commit a6c3ae9

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

tests/web-ui-smoke.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,31 @@ probe "/api/detect-environment" "/api/detect-environment" 200
6363
probe "/api/search?q=foo" "/api/search?q=foo" 200
6464
probe "/api/search (no q -> 400)" "/api/search" 400
6565

66-
WS_ID=$(curl "${CURL_FLAGS[@]}" "$BASE/api/workspaces" | python3 -c "
66+
# Find a non-global workspace id to drive the workspace-scoped probes.
67+
# Failing to PARSE /api/workspaces is a real bug (200 with malformed JSON
68+
# would otherwise slip through as a false green), so the python parse
69+
# runs without `2>/dev/null` and exit-status is checked separately.
70+
if WS_ID=$(curl "${CURL_FLAGS[@]}" "$BASE/api/workspaces" | python3 -c "
6771
import sys, json
6872
data = json.load(sys.stdin)
6973
for w in data:
7074
if w.get('id') and w['id'] != 'global':
7175
print(w['id'])
7276
break
73-
" 2>/dev/null)
74-
75-
if [ -n "$WS_ID" ]; then
76-
echo ""
77-
echo "=== Workspace-scoped routes (WS=$WS_ID) ==="
78-
probe "/workspace/<id>" "/workspace/$WS_ID" 200
79-
probe "/api/workspaces/<id>" "/api/workspaces/$WS_ID" 200
80-
probe "/api/workspaces/<id>/tabs" "/api/workspaces/$WS_ID/tabs" 200
77+
"); then
78+
if [ -n "$WS_ID" ]; then
79+
echo ""
80+
echo "=== Workspace-scoped routes (WS=$WS_ID) ==="
81+
probe "/workspace/<id>" "/workspace/$WS_ID" 200
82+
probe "/api/workspaces/<id>" "/api/workspaces/$WS_ID" 200
83+
probe "/api/workspaces/<id>/tabs" "/api/workspaces/$WS_ID/tabs" 200
84+
else
85+
echo ""
86+
echo "[skip] no non-global workspace found; workspace-scoped probes skipped"
87+
fi
8188
else
82-
echo ""
83-
echo "[skip] no non-global workspace found; workspace-scoped probes skipped"
89+
printf "\n [FAIL] %-44s parse error on /api/workspaces payload\n" "workspace-id extraction"
90+
fail=$((fail + 1))
8491
fi
8592

8693
echo ""

0 commit comments

Comments
 (0)