fix: move /execute-stream route BEFORE /{prompt_id} catch-all (FastAPI route ordering)
Root cause: FastAPI matches routes in definition order. The /{prompt_id}
catch-all at line 257 was intercepting /execute-stream requests before
the specific route handler could match.
Fix: Moved execute-stream definition (with section header + imports)
to line 257, before the catch-all route (now at line 414).
This resolves the 'Connection to server lost' error in SSE streaming.
This commit is contained in:
parent
09d1b6f967
commit
879a3a58d7
|
|
@ -254,6 +254,11 @@ def import_prompts(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
|
# UNIFIED PROMPT SYSTEM (Issue #28 Phase 2)
|
||||||
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
from prompt_executor import execute_prompt_with_data
|
||||||
from models import UnifiedPromptCreate, UnifiedPromptUpdate
|
from models import UnifiedPromptCreate, UnifiedPromptUpdate
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -403,9 +408,8 @@ async def execute_unified_prompt_stream(
|
||||||
"Connection": "keep-alive",
|
"Connection": "keep-alive",
|
||||||
"X-Accel-Buffering": "no" # Disable nginx buffering
|
"X-Accel-Buffering": "no" # Disable nginx buffering
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
# NOTE: /execute-stream MUST be defined BEFORE /{prompt_id} to avoid route conflicts
|
|
||||||
# FastAPI matches routes in order, so specific routes must come before catch-all patterns
|
|
||||||
|
|
||||||
@router.get("/{prompt_id}")
|
@router.get("/{prompt_id}")
|
||||||
def get_prompt(prompt_id: str, session: dict=Depends(require_auth)):
|
def get_prompt(prompt_id: str, session: dict=Depends(require_auth)):
|
||||||
|
|
@ -1590,15 +1594,7 @@ def reset_prompt_to_default(prompt_id: str, session: dict=Depends(require_admin)
|
||||||
return {"ok": True}
|
return {"ok": True}
|
||||||
|
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
@router.post("/execute")
|
||||||
# UNIFIED PROMPT SYSTEM (Issue #28 Phase 2)
|
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
|
||||||
|
|
||||||
from prompt_executor import execute_prompt_with_data
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def execute_unified_prompt(
|
async def execute_unified_prompt(
|
||||||
prompt_slug: str = Query(..., description="Slug of prompt to execute"),
|
prompt_slug: str = Query(..., description="Slug of prompt to execute"),
|
||||||
modules: Optional[dict] = None,
|
modules: Optional[dict] = None,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user