Root cause
Authentication & access control
The change registers a compatibility route that invokes the selected agent.
How AI contributed: Flawed AI-written codePublished Aug 25, 2026 in
mervinpraison/praisonaiAll 19 findings in this repository
Provisional finding. Full causal and release verification remains incomplete.
Root cause
The change registers a compatibility route that invokes the selected agent.
Fix
The middleware rejects a missing or incorrect token before handling the request.
Case facts
@@ -289,3 +335,16 @@ status_code=500, ) + # Add simple /agents/{agent_name} endpoint for n8n compatibility+ @app.post("/agents/{agent_name}")+ async def invoke_single_agent(agent_name: str, request: Request):+ """Invoke a specific agent by name (n8n compatibility endpoint)."""+ try:+ body = await request.json()+ query = body.get("query", "") or body.get("message", "")+ + if not query:+ raise HTTPException(status_code=400, detail="No query or message provided")+ + # Use the registered agent if available+ try:@@ -22,5 +39,18 @@+ path = request.url.path+ if path in public or path.startswith("/__praisonai__/"):+ return await call_next(request)+ auth = request.headers.get("Authorization", "")+ header_key = request.headers.get("X-API-Key", "")+ token = auth[7:] if auth.startswith("Bearer ") else header_key+ if not token or not hmac.compare_digest(token, api_key):+ return JSONResponse({"error": "Unauthorized"}, status_code=401)+ return await call_next(request)++ app.add_middleware(APIKeyMiddleware)++ class ServeHandler: """ CLI handler for serve operations. Commands:AI-assisted change d1bf0011c64e42f8716f28d5c765551b92c02838f43b08611c5a035011f1942a · Fix f39cbff135b022eb9525d52f3037f20d619f50bb2680d544dadc5b18c7a5f35b