Skip to content

fix(streaming): handle None chunks in _chunk_to_dict - #102

Open
clarkestu wants to merge 1 commit into
Continuum-AI-Corp:mainfrom
clarkestu:fix/chunk-to-dict-guard
Open

clarkestu wants to merge 1 commit into
Continuum-AI-Corp:mainfrom
clarkestu:fix/chunk-to-dict-guard

Conversation

@clarkestu

@clarkestu clarkestu commented Sep 14, 2026

Copy link
Copy Markdown

Orca-Code-Review — push 1

Severity Count
P0 0
P1 0
P2 0
P3 0

✅ no blocking findings

Some LiteLLM stream wrappers yield None as a heartbeat/keepalive signal between real chunks. Without a guard, the fallback dict(None) in _chunk_to_dict raises TypeError: cannot convert NoneType object to dict iteration, which propagates through the streaming try/except Exception block and kills the stream mid-flight — the client sees a 500 error frame instead of a seamless continuation.

Fix: add an explicit None check at the top of _chunk_to_dict returning {}. The streaming loop already handles empty dicts gracefully (no _orca_meta, no usage, no model — yields a harmless empty SSE frame that clients ignore).

Tests: tests/unit/test_chunk_to_dict_guard.py — covers None, dict passthrough, Pydantic model, and iterable fallback paths.

Some LiteLLM stream wrappers yield None as a heartbeat/keepalive signal.
Without a guard, the fallback dict(None) raises TypeError and kills the
stream for a non-event — the client sees a 500 mid-stream instead of a
seamless continuation.

Add an explicit None check at the top of _chunk_to_dict returning an
empty dict. The streaming loop already handles empty dicts gracefully
(no _orca_meta, no usage, no model — yields a harmless empty frame).

@orcacode-review orcacode-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐳 OrcaCode Review

No findings — nothing to flag in this PR. Great work!

OrcaCode Review — Route Smarter. Ship Safer. Spend Less.
Engine-reported: 298 calls · 12.3M tokens · 98% cached

❤️ Share · Install OrcaCode Review

Free on GitHub — the review runs on your own OrcaRouter key. If it helped, a shout-out goes a long way.

Share: X · Reddit · LinkedIn
Follow: X · Discord · LinkedIn · OrcaRouter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant