POST /v1/organizations/{id}/logo returns 500 — MissingGreenlet during response serialization
## Bug `POST /v1/organizations/{id}/logo` returns **500** even though the upload succeeds. The file is saved to storage and `logo_url` is updated in the database — but the response serialization fails, so the client sees an error and shows a failure toast for what was actually a successful save. ## Error ``` fastapi.exceptions.ResponseValidationError: loc: ('response', 'updated_at') msg: "MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place?" ``` ## What's happening 1. File is saved to storage ✅ 2. DB is updated (`logo_url` set) ✅ 3. Endpoint returns an SQLAlchemy `Organization` object 4. FastAPI tries to serialize the response via Pydantic 5. Pydantic touches `updated_at`, which SQLAlchemy tries to lazy-load — but the async session has already been released → `MissingGreenlet` → 500 ## Reference: ring logo endpoint works `POST /v1/groups/{id}/logo` returned **200** for the same request in the same logs, so whatever pattern it uses (eager load / explicit refresh / return a pre-built response model) is the fix shape for the org endpoint. ## Fix candidates (pick whichever matches codebase style) 1. `await session.refresh(org)` inside the transaction before returning 2. Eager-load `updated_at` (e.g. `selectinload`) so it's already populated when the session closes 3. Build the response from a plain dict / Pydantic model **inside** the session and return that instead of the ORM object ## Frontend impact None — the frontend is correct. A 500 is a 500, and the failure toast fires as designed. No changes needed in the wizard. ## Found by Debugging onboarding logo upload
0 Comments
Sign in to comment
No comments yet. Be the first to share your thoughts!
