MEDIUM: Fix mixed async/sync API endpoints with fire-and-forget patterns #40
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
bot/api.py mixes async def and def endpoint handlers inconsistently. Several sync endpoints use globals.client.loop.create_task() to schedule async work but return a success response immediately, with no error feedback to the caller.
Example Pattern (problematic)
Problems with this pattern:
Known Affected Endpoints
Proposed Solution
Option A: Make endpoints properly async (preferred)
Option B: Background tasks with status tracking
For long-running operations, use FastAPI BackgroundTasks with a job status endpoint:
from fastapi import BackgroundTasks
Option C: At minimum, add error callbacks
Impact
Files Affected