Skip to content

Renderer: apiFetch JSON-parses body before ok-check and mishandles FastAPI 422 detail arrays #44

Description

@I4cTime

Summary

apiFetch calls JSON.parse(response.body) before inspecting response.ok, so any non-JSON body (uvicorn plain-text 500, empty/truncated body) throws SyntaxError before the status is read, masking the real error and producing unhandled rejections. Also, FastAPI 422 detail is an array of objects, so new Error(data.detail) yields "[object Object]".

Location

electron/renderer/src/lib/api.ts:31-46

Notes

Also (L31-35): the non-Electron fallback hardcodes port 8000 and sends no Authorization header, so it can never work (backend binds an ephemeral port and mints a required token) - running the renderer in a plain browser tab breaks all data loading.

Fix

Check response.ok before parsing; parse detail arrays into a readable message; either fix or remove the non-Electron fallback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions