Skip to content

Commit a7d0bdc

Browse files
committed
Handle invalid localized theme payloads and fix se theme schema
1 parent c2ef37a commit a7d0bdc

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

  • recorder-backend

recorder-backend/app/routers/content.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44

55
from fastapi import APIRouter, HTTPException, Path, Query
6+
from pydantic import ValidationError
67

78
from app.models import Schedule, Theme, ScheduleAvailability, ThemeAvailability
89
from app.schedule_processing import pre_process_schedule
@@ -33,6 +34,9 @@ async def load_schedule(
3334
schedule = Schedule(**schedule_dict)
3435
schedule.id = schedule_id
3536
return pre_process_schedule(schedule)
37+
except ValidationError as e:
38+
logger.error(f"Invalid schedule payload for {schedule_id}/{lang}: {e}")
39+
raise HTTPException(status_code=422, detail="Invalid schedule payload")
3640
except StorageError as e:
3741
logger.error(f"Error loading schedule {schedule_id}: {e}")
3842
raise HTTPException(status_code=404, detail="Schedule not found")
@@ -87,6 +91,9 @@ async def load_theme(
8791
theme = Theme(**theme_dict)
8892
theme.id = theme_id
8993
return theme
94+
except ValidationError as e:
95+
logger.error(f"Invalid theme payload for {theme_id}/{lang}: {e}")
96+
raise HTTPException(status_code=422, detail="Invalid theme payload")
9097
except StorageError as e:
9198
logger.error(f"Error loading theme {theme_id}: {e}")
9299
raise HTTPException(status_code=404, detail="Theme not found")

recorder-backend/content/dev/themes/14193cf4-4720-43fb-afe2-2c1f700335a4/se.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{
2424
"itemId": "602a6168-f980-483e-be7b-d11614ddb5ac",
2525
"kind": "media",
26-
"itemType": "Choose one of image, audio, text, video",
26+
"itemType": "image",
2727
"typeId": null,
2828
"isRecording": true,
2929
"start": {
@@ -48,7 +48,7 @@
4848
{
4949
"itemId": "970c4c8b-e277-41aa-801a-b4585549239f",
5050
"kind": "media",
51-
"itemType": "Choose one of image, audio, text, video",
51+
"itemType": "image",
5252
"typeId": null,
5353
"isRecording": true,
5454
"start": {
@@ -73,7 +73,7 @@
7373
{
7474
"itemId": "5d77f827-1ba3-49fd-9edd-a6c842a7e6d3",
7575
"kind": "media",
76-
"itemType": "Choose one of image, audio, text, video",
76+
"itemType": "image",
7777
"typeId": null,
7878
"isRecording": true,
7979
"start": {
@@ -98,7 +98,7 @@
9898
{
9999
"itemId": "e7db33fd-d514-450a-bb7b-d8dbc01424df",
100100
"kind": "media",
101-
"itemType": "Choose one of image, audio, text, video",
101+
"itemType": "image",
102102
"typeId": null,
103103
"isRecording": true,
104104
"start": {
@@ -123,7 +123,7 @@
123123
{
124124
"itemId": "b54de1ef-d7be-4018-9ca4-0a0e6a5cbdd8",
125125
"kind": "media",
126-
"itemType": "Choose one of image, audio, text, video",
126+
"itemType": "image",
127127
"typeId": null,
128128
"isRecording": true,
129129
"start": {
@@ -148,7 +148,7 @@
148148
{
149149
"itemId": "0da9eb1e-bcef-4200-a846-e2fbe844d904",
150150
"kind": "media",
151-
"itemType": "Choose one of image, audio, text, video",
151+
"itemType": "image",
152152
"typeId": null,
153153
"isRecording": true,
154154
"start": {
@@ -173,7 +173,7 @@
173173
{
174174
"itemId": "73688cf3-73e6-4dfe-9edd-53e465344330",
175175
"kind": "media",
176-
"itemType": "Choose one of image, audio, text, video",
176+
"itemType": "image",
177177
"typeId": null,
178178
"isRecording": true,
179179
"start": {
@@ -196,9 +196,9 @@
196196
}
197197
},
198198
{
199-
"itemId": "ae7fda4f-76c9-4815-b6a1-351a407582ea",
199+
"itemId": "9dcf4308-c08a-44b1-973f-16a502624323",
200200
"kind": "media",
201-
"itemType": "Choose one of image, audio, text, video",
201+
"itemType": "image",
202202
"typeId": null,
203203
"isRecording": true,
204204
"start": {
@@ -223,7 +223,7 @@
223223
{
224224
"itemId": "ae7fda4f-76c9-4815-b6a1-351a407582ea",
225225
"kind": "media",
226-
"itemType": "Choose one of image, audio, text, video",
226+
"itemType": "image",
227227
"typeId": null,
228228
"isRecording": true,
229229
"start": {
@@ -248,7 +248,7 @@
248248
{
249249
"itemId": "165158cf-7b5d-429a-9a91-02f833fc3851",
250250
"kind": "media",
251-
"itemType": "Choose one of image, audio, text, video",
251+
"itemType": "image",
252252
"typeId": null,
253253
"isRecording": true,
254254
"start": {
@@ -273,7 +273,7 @@
273273
{
274274
"itemId": "c41f5b17-34c5-46a5-a1ec-12546a1530ad",
275275
"kind": "media",
276-
"itemType": "Choose one of image, audio, text, video",
276+
"itemType": "image",
277277
"typeId": null,
278278
"isRecording": true,
279279
"start": {

0 commit comments

Comments
 (0)