move_slide raises unhandled ValueError if the slide was already deleted #15
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
paul_loth/krautspaceTV#15
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
`db.move_slide()` does:
```python
slides = await list_slides()
ids = [s["id"] for s in slides]
idx = ids.index(slide_id)
```
If `slide_id` no longer exists (e.g. deleted by someone else between page load and clicking "Up"/"Down" — plausible given the admin UI is intentionally open to multiple concurrent users), `list.index()` raises `ValueError: ... is not in list`, uncaught, producing a raw 500 from `POST /admin/slides/{slide_id}/move`.
Suggested fix
Guard with something like `if slide_id not in ids: return` before calling `.index()`, mirroring the "slide not found → no-op" behavior already used elsewhere (e.g. `toggle_slide`/`delete_slide` are naturally no-ops on a missing id since they're plain `UPDATE`/`DELETE` statements).
Fixed in
0bcc65e: move_slide now checks slide_id in ids before calling .index(), no-oping instead of raising if the slide was already deleted. Verified live: POST .../slides/99999/move now returns the normal 303 redirect instead of a 500.