Skip to content

Swallowed errors: serve.py 500s on bad input, capture proxy kills connections, has_cuda silent fallback #8

Description

@thedataengineer

Places where a failure is swallowed or misreported:

  1. serve.py:1473 blanket except turns validation errors into 500s. The whole do_POST route table is wrapped in one except Exception that returns 500 {type}: {e}. Unchecked field reads like b["model"] (serve.py:1440), b["prompt"] (:1447), b["messages"] (:1459) surface as 500 KeyError: 'model' instead of a 4xx with a usable message.

  2. capture.py proxy dies instead of returning an error body. capture.py:113 does json.loads(self.rfile.read(int(self.headers["Content-Length"]))) with no handling for a missing header or bad JSON, and _serve() (capture.py:148) has no try/except around model.chat(). Any failure kills the connection, so the agent under capture sees a transport error rather than an OpenAI-shaped error response. That undercuts the drop-in-proxy contract, since real agent frameworks retry on API errors but often crash on transport errors.

  3. backends/torch.py:74 has_cuda() is a bare except Exception: return False with no annotation or log. A broken CUDA install silently degrades select_backend("auto") to CPU, which contradicts the accel.py property of logging exactly what was enabled.

  4. serve.py:788-789 and serve.py:824-825 swallow torch.cuda.empty_cache() failures with unannotated except Exception: pass. In the VRAM-pressure retry path the subsequent _load() then fails opaquely, and clear_vram() reports {"unloaded": n} success even when the cache clear threw.

  5. Frontend: 23 swallowed promise rejections (.catch(() => {}) across App.tsx, pages/Models.tsx, pages/Dashboard.tsx, pages/Datasets.tsx, pages/Runs.tsx, pages/Playground.tsx, pages/Train.tsx, pages/Machines.tsx). Polling loops recover, but a first-load failure renders as an empty state with no error surface, indistinguishable from "no data yet".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions