fix http exceptions
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
Jake Walker 2025-02-05 23:32:27 +00:00
parent f0b4a38775
commit a7aca14def
No known key found for this signature in database

View file

@ -142,20 +142,20 @@ def update_podcast_image(
if image is not None and image.size > 0: if image is not None and image.size > 0:
if not (image.filename.endswith(".jpg") or image.filename.endswith(".png")): if not (image.filename.endswith(".jpg") or image.filename.endswith(".png")):
return HTTPException( raise HTTPException(
400, detail="The uploaded podcast image must be a jpg or png" 400, detail="The uploaded podcast image must be a jpg or png"
) )
im = Image.open(image.file) im = Image.open(image.file)
if im.size[0] != im.size[1] or im.size[0] < 1400 or im.size[0] > 3000: if im.size[0] != im.size[1] or im.size[0] < 1400 or im.size[0] > 3000:
return HTTPException( raise HTTPException(
400, 400,
detail="The uploaded podcast image must be square and between 1400x1400px and 3000x3000px in size", detail="The uploaded podcast image must be square and between 1400x1400px and 3000x3000px in size",
) )
if im.mode != "RGB": if im.mode != "RGB":
return HTTPException( raise HTTPException(
400, detail="The uploaded podcast image must be in RGB format" 400, detail="The uploaded podcast image must be in RGB format"
) )
@ -489,7 +489,7 @@ def get_episode_or_cover(session: SessionDep, podcast_id: str, filename: str):
) and filename == podcast.image_filename: ) and filename == podcast.image_filename:
return FileResponse(settings.directory / podcast.image_filename) return FileResponse(settings.directory / podcast.image_filename)
return HTTPException(status_code=404, detail="File not found") raise HTTPException(status_code=404, detail="File not found")
@app.get("/{full_path:path}") @app.get("/{full_path:path}")
@ -497,7 +497,7 @@ async def serve_app(full_path: str):
if not full_path.startswith("api/"): if not full_path.startswith("api/"):
return FileResponse("dist/index.html") return FileResponse("dist/index.html")
return HTTPException(status_code=404, detail="Not found") raise HTTPException(status_code=404, detail="Not found")
use_route_names_as_operation_ids(app) use_route_names_as_operation_ids(app)