edit_slide_form/update_slide crash if a slide's stored type is no longer in REGISTRY #13

Closed
opened 2026-07-28 21:40:53 +00:00 by paulloth1 · 1 comment
paulloth1 commented 2026-07-28 21:40:53 +00:00 (Migrated from github.com)

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`.

## 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\`.
paulloth1 commented 2026-07-28 21:43:36 +00:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
paul_loth/krautspaceTV#13
No description provided.