sharpca opened a new pull request, #1016:
URL: https://github.com/apache/burr/pull/1016

   ## Why are these changes needed?
   
   `Application.astream_result()` ends a stream in two places: the success path 
and the exception handler. The exception handler called `post_end_stream` 
unconditionally, but `pre_start_stream` only runs for streaming actions. A 
non-streaming action that raises therefore fans out `post_end_stream` for a 
stream that was never started.
   
   Adapters that keep per-stream state blow up there. 
`LocalTrackingClient.post_end_stream` looks the stream up in `stream_state` -- 
which only `pre_start_stream` populates -- so it raised `KeyError` from inside 
the handler and replaced the action's own exception with an unrelated one. 
Because the handler runs while the original exception is in flight, users saw a 
bare `KeyError` with no trace of the real failure, even when their application 
code raised something perfectly readable.
   
   This tracks whether `pre_start_stream` completed and only fans out 
`post_end_stream` when it did. Streams that did start are cleaned up exactly as 
before, so `stream_state` bookkeeping is unchanged for the streaming path.
   
   Fixes #999
   
   ## Related issue number
   
   #999
   
   ## Checks
   
   - [x] I've successfully run `make lint && make test` (see notes below on the 
local equivalent)
   - [x] I've added tests where applicable.
   - [ ] For core features, I have updated the documentation.
   - [ ] For user-impacting features, I have updated the changelog.
   
   Verification details:
   
   - `tests/core/test_application.py` -- 143 passed
   - `tests/tracking/test_local_tracking_client.py` -- 17 passed, 1 skipped
   - `tests/core` -- 426 passed; the 9 failures are all in 
`test_graphviz_display.py` and come from the optional `graphviz` package being 
absent in this environment, unrelated to this change
   - `black --line-length 100 --check` passes
   
   Two regression tests were added:
   
   - `test_astream_result_non_streaming_exception_skips_post_end_stream` 
(core): asserts the lifecycle hook is not invoked when the action is not 
streaming
   - `test_astream_result_preserves_non_streaming_action_exception` (tracking): 
asserts the action's `ValueError` reaches the caller with the built-in local 
tracker attached
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to