andreahlert commented on PR #680: URL: https://github.com/apache/burr/pull/680#issuecomment-4117941078
> Good fix for a real issue! The `try/except` approach in the single-step functions is clean — checking `state_update is None` correctly distinguishes between "generator crashed before completing" and "generator yielded a final state in its `finally` block." > > Two items to address: > > 1. **`caught_exc` should be logged** in the multi-step functions — it's currently assigned (`caught_exc = e`) but never read afterward. Please log it (e.g., `logger.warning(...)`) so that exceptions aren't silently swallowed. Users need visibility into what went wrong even when the stream completes gracefully. > 2. **Tests needed.** The reproduction case from #581 translates directly into a test. Please add tests covering: > > * Streaming action with `try/except/finally` that yields state update in `finally` → completes gracefully > * Streaming action that raises without yielding state → exception still propagates > * Both single-step and multi-step variants > > Also worth discussing: the multi-step guard (`if result is None: raise`) is more permissive than the single-step guard (`if state_update is None: raise`). In multi-step, if the generator crashes after yielding some items but before producing the "final" result, the reducer silently runs on partial data. Is this the intended behavior? All three points addressed. Added logger.warning(...) with exc_info=True in all 4 functions (not just multi-step). Removed the dead caught_exc variable entirely. Added 8 tests covering graceful shutdown and exception propagation for both single-step and multi-step, sync and async. On the multi-step guard discussion: kept if result is None: raise but the warning now explicitly tells the user the reducer is running on potentially partial data, so there's full visibility without changing the current behavior. Also ran additional review passes (on an isolated environment - thanks to Claude for that) that caught a few extra issues beyond what was flagged: added logging in the single-step functions too (not just multi-step), fixed a count increment asymmetry between sync and async single-step variants, and fixed test fixtures where stream_run wasn't a proper generator function (missing yield after raise). IMHO, now we're ready to merge. But I think worth take an extra look. -- 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]
