llama-stack-mirror/llama_stack/distribution
Ben Browning cfa4b61a01 fix: Additional streaming error handling
This expands the `test_sse` test suite and fixes some edge cases with
bugs in our SSE error handling to ensure streaming clients always get
a proper error response.

First, we handle the case where a client disconnects before we
actually start streaming the response back. Previously we only handled
the case where a client disconnected as we were streaming the
response, but there was an edge case where a client disconnecting
before we streamed any response back did not trigger our logic to
cleanly handle that disconnect.

Second, we handle the case where an error is thrown from the server
before the actual async generator gets created from the provider. This
happens in scenarios like the newly merged OpenAI API input
validation, where we eagerly raise validation errors before returning
the async generator object that streams the responses back.

Tested via:

```
python -m pytest -s -v tests/unit/server/test_sse.py
```

Both test cases failed before, and passed afterwards. The test cases
were written based on me experimenting with actual clients that would
do bad things like randomly disconnect or send invalid input in
streaming mode and I hit these two cases, where things were
misbehaving in our error handling.

Signed-off-by: Ben Browning <bbrownin@redhat.com>
2025-04-23 13:04:16 -04:00
..
routers fix: Return HTTP 400 for OpenAI API validation errors (#2002) 2025-04-23 17:48:32 +02:00
server fix: Additional streaming error handling 2025-04-23 13:04:16 -04:00
store fix: handle registry errors gracefully (#1732) 2025-03-20 15:24:07 -07:00
ui feat: add tool name to chat output in playground (#1996) 2025-04-23 15:57:54 +02:00
utils feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
__init__.py API Updates (#73) 2024-09-17 19:51:35 -07:00
access_control.py feat: make sure agent sessions are under access control (#1737) 2025-03-21 07:31:16 -07:00
build.py feat: allow building distro with external providers (#1967) 2025-04-18 17:18:28 +02:00
build_conda_env.sh chore: remove straggler references to llama-models (#1345) 2025-03-01 14:26:03 -08:00
build_container.sh feat: allow building distro with external providers (#1967) 2025-04-18 17:18:28 +02:00
build_venv.sh chore: remove straggler references to llama-models (#1345) 2025-03-01 14:26:03 -08:00
client.py chore: move all Llama Stack types from llama-models to llama-stack (#1098) 2025-02-14 09:10:59 -08:00
common.sh fix: Fixing some small issues with the build scripts (#1132) 2025-02-19 22:20:49 -08:00
configure.py feat: add provider API for listing and inspecting provider info (#1429) 2025-03-13 15:07:21 -07:00
datatypes.py feat: allow building distro with external providers (#1967) 2025-04-18 17:18:28 +02:00
distribution.py feat: allow building distro with external providers (#1967) 2025-04-18 17:18:28 +02:00
inspect.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
library_client.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
providers.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
request_headers.py feat(server): add attribute based access control for resources (#1703) 2025-03-19 21:28:52 -07:00
resolver.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
stack.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
start_stack.sh docs: Update docs and fix warning in start-stack.sh (#1937) 2025-04-11 16:26:17 -07:00