edit_slide_form/update_slide crash if a slide's stored type is no longer in REGISTRY #13
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#13
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
In `backend/app.py`, both `edit_slide_form` and `update_slide` do:
```python
slide_type = REGISTRY.get(slide["type"])
...
config = {f.name: form.get(f.name, "") for f in slide_type.config_fields}
```
without checking whether `slide_type` is `None` first (unlike `create_slide`, which does check). If a slide's stored `type` string no longer matches any registered slide type — e.g. after a future code change removes/renames a slide type while old rows referencing it still exist in `signage.db` — this raises `AttributeError: 'NoneType' object has no attribute 'config_fields'`.
Low likelihood today (all currently-registered types have existed since the DB schema was created), but a latent crash waiting for the next slide-type refactor.
Suggested fix
Add the same `if slide_type is None: return RedirectResponse(...)` guard already used elsewhere (e.g. `create_slide`) to both `edit_slide_form` and `update_slide`.
Fixed in
73f0db2: edit_slide_form and update_slide now both guard on slide_type is None (matching the existing pattern in create_slide) and redirect back to / instead of crashing.