GET /proxy with no parameters raises an unhandled exception (500) #14

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

Problem

`/proxy` (backend/app.py) defaults `url: str = ""` when no `slide_id` is given. Calling it with no parameters at all (`GET /proxy`) passes an empty string to `httpx.AsyncClient().get(url, ...)`, which raises an exception (invalid/missing URL) that nothing catches — FastAPI turns it into a raw 500.

Reproduced: `curl http://127.0.0.1:8081/proxy` → `500`.

Since `/proxy` is intentionally open on the network (by design, see #2), it should fail cleanly for bad/missing input rather than raising.

Suggested fix

Validate up front: if `slide_id` is None and `url` is empty (or doesn't look like a valid absolute URL), return a 400 with a short message instead of proceeding to the fetch.

## Problem \`/proxy\` (backend/app.py) defaults \`url: str = ""\` when no \`slide_id\` is given. Calling it with no parameters at all (\`GET /proxy\`) passes an empty string to \`httpx.AsyncClient().get(url, ...)\`, which raises an exception (invalid/missing URL) that nothing catches — FastAPI turns it into a raw 500. Reproduced: \`curl http://127.0.0.1:8081/proxy\` → \`500\`. Since \`/proxy\` is intentionally open on the network (by design, see #2), it should fail cleanly for bad/missing input rather than raising. ## Suggested fix Validate up front: if \`slide_id\` is None and \`url\` is empty (or doesn't look like a valid absolute URL), return a 400 with a short message instead of proceeding to the fetch.
paulloth1 commented 2026-07-28 21:52:42 +00:00 (Migrated from github.com)

Fixed in 0bcc65e: /proxy now returns 400 if url is missing/has no scheme, and 502 (instead of an unhandled 500) if the upstream fetch itself fails. Verified live: bare GET /proxy -> 400, url pointing at an unreachable host -> 502, normal slide_id proxying still works (200).

Fixed in 0bcc65e: /proxy now returns 400 if url is missing/has no scheme, and 502 (instead of an unhandled 500) if the upstream fetch itself fails. Verified live: bare GET /proxy -> 400, url pointing at an unreachable host -> 502, normal slide_id proxying still works (200).
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#14
No description provided.