-
Couldn't load subscription status.
- Fork 201
Use SSE for wait_for_rollouts #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Use SSE for wait_for_rollouts #207
Conversation
| data = [rollout.model_dump(mode="json") for rollout in rollouts] | ||
| yield f"data: {json.dumps(data)}\n\n" | ||
|
|
||
| return StreamingResponse(event_stream(), media_type="text/event-stream") |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
To address the information exposure problem, we should prevent returning detailed exception information to external users. Instead, only a generic error message should be sent, such as "An internal error has occurred". The detailed exception information (including potentially the stack trace) should be logged server-side using the logging module or similar tooling.
Steps:
- In the
event_stream()function, replace the use ofstr(exc)in the yielded SSE data with a generic error string. - Log the detailed exception and stack trace using
logger.error(traceback.format_exc())or equivalent. - Do not change any application logic except for the error reporting in the SSE stream; maintain existing behavior and error-handling structure.
The required edits are confined to the relevant block in the shown code within agentlightning/store/client_server.py.
-
Copy modified lines R366-R367
| @@ -363,7 +363,8 @@ | ||
| timeout=payload.timeout, | ||
| ) | ||
| except Exception as exc: # pragma: no cover - surfaced via SSE | ||
| error_payload = {"error": str(exc)} | ||
| logger.error("Exception in wait_for_rollouts SSE", exc_info=True) | ||
| error_payload = {"error": "An internal error has occurred."} | ||
| yield "event: error\n" | ||
| yield f"data: {json.dumps(error_payload)}\n\n" | ||
| return |
|
/ci |
|
✅ CI retrigger requested by @ultmaster. Closed & reopened the PR to fire |
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68fa5a8534b4832eb5385a9bbfe33194