fix: pass through a response that is JSON but not an object - #65
Draft
rickstaa wants to merge 1 commit into
Draft
Conversation
call_runner picked its return path from Content-Type alone, so a body that is valid JSON but not an object matched neither: it took the JSON branch, failed the isinstance check, and raised. A runner proxying somebody else's API does not choose its response shape, and a top-level array is a common one, so it now comes back unparsed in `content` the way an image or ndjson already does. Objects are unchanged, session_id included, and the only path that behaves differently is the one that used to raise. Strictness stays where protocol fields are read out of the body: proxy create and trickle channel remove. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
rickstaa
force-pushed
the
fix/call-runner-json-array
branch
from
August 18, 2026 10:36
9cd3c07 to
acb13b4
Compare
rickstaa
marked this pull request as draft
August 18, 2026 12:30
Member
Author
|
@josh please ignore this was my agent testing things. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #64.
call_runnerpicks its return path fromContent-Typealone: JSON parses intoresult.data, anything else arrives unparsed inresult.content. A body that is valid JSON but not an object matched neither. It took the JSON branch, failedisinstance(data, dict), and raisedLive runner call expected JSON object, got list.A runner that proxies somebody else's API does not choose its response shape, and a top-level array is a common one — every Hugging Face inference task except text-to-image answers with one. Such a runner could not be called through the SDK at all. The workaround was for the runner to stop advertising JSON so the body took the opaque-bytes path, which in runner-app-examples#82 meant nginx relabelling a JSON body as
text/plain.What changed
Non-object JSON is now handed back unparsed in
result.content, exactly as an image or ndjson already is, withresult.content_typeleft sayingapplication/jsonso the caller knows what it is holding.Objects keep today's behavior including
session_idextraction, so the only path that behaves differently is the one that used to raise. Strictness stays where the body carries protocol fields:proxy createandtrickle channel removeare untouched.test_json_array_still_rejectedbecomestest_json_array_returns_raw, and a scalar case joins it, since the rule is about being an object rather than about arrays.Testing
uv run --frozen --group test pytest— 245 passed.data: {} content: b'[{"label": "llama", "score": 0.99}]'instead of raising.