Skip to content

fix(endpoint): prevent KeyError in Job.stream() when stream key is missing or None - #745

Open
Mouhand-Kaddo wants to merge 1 commit into
runpod:mainfrom
Mouhand-Kaddo:fix/sync-job-stream-missing-key
Open

Mouhand-Kaddo wants to merge 1 commit into
runpod:mainfrom
Mouhand-Kaddo:fix/sync-job-stream-missing-key

Conversation

@Mouhand-Kaddo

Copy link
Copy Markdown

Calling Job.stream() on a sync endpoint raises KeyError: 'stream' (or TypeError when "stream": None) if /stream/{job_id} returns a terminal state (FAILED, TIMED_OUT, or COMPLETED) without a "stream" key in the payload. The next line already used .get("stream", []), and the async runner only guarded missing keys, leaving "stream": None unhandled in both.

Both sync and async Job.stream() now normalize stream_partial.get("stream") or [] before checking chunk length and yielding outputs, so terminal and in-progress responses with a missing or None "stream" field exit or continue polling cleanly. Added unit tests covering FAILED, TIMED_OUT, and COMPLETED responses with missing and None "stream" values alongside normal chunk streaming.

Created with Gemini 4 Neon in T3 Code.

This branch has not been deployed

No deployments
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