Commit 017d408
committed
review: 2 CodeRabbit findings on PR #30 — response-shape parity + alias-vote drift guard
* api/composers.py — get_composer() returned three different shapes for
the same conceptual `conversation` field depending on which branch
resolved the composer:
- list_composers (line 89): `c["conversation"] = c.get("conversation") or []`
- get_composer per-workspace (line 157): `return jsonify(local.raw)` — raw, no normalisation
- get_composer global fallback (line 185): `payload.setdefault("conversation", [])` — fills missing but not None
All three sites now use the line-89 idiom, so the endpoint family
returns an identical shape regardless of source.
* api/workspaces.py — `_infer_invalid_workspace_aliases()` was reparsing
raw composer_rows with `json.loads` + bare `except Exception` *before*
the per-row Composer.from_dict gates in list_workspaces() /
get_workspace_tabs() ran. That meant schema-drifted composers could
still cast votes in the workspace-alias inference and misassign
otherwise-valid composers to the wrong workspace. Now gates via
`Composer.from_dict(...)` with a narrow
`(SchemaError, JSONDecodeError, TypeError, ValueError)` catch.
Existing test_majority_vote_alias_selection fixture predated the
strict createdAt gate from issue #24; added `createdAt` to each of
the three composer rows so the fixture reflects real production shape.
New test_drifted_composer_does_not_skew_vote pins the regression:
seeds two well-formed boost-ws votes plus one drifted row that would
vote for team-ws if counted, asserts the alias resolves to boost-ws.
Verified:
- mypy --ignore-missing-imports --no-strict-optional . → Success
- ruff check api/ utils/ scripts/export.py app.py → All checks passed
- unittest discover tests → 224 / 224 OK (was 223 + 1 new regression test)1 parent 4b8548a commit 017d408
3 files changed
Lines changed: 62 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
| |||
182 | 189 | | |
183 | 190 | | |
184 | 191 | | |
185 | | - | |
| 192 | + | |
186 | 193 | | |
187 | 194 | | |
188 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
450 | | - | |
451 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
452 | 459 | | |
453 | 460 | | |
454 | 461 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
49 | 90 | | |
50 | 91 | | |
51 | 92 | | |
0 commit comments