Repository navigation
fix(api): accept an abort request without a body - #6309
Merged
qinxuye merged 4 commits intoDec 4, 2026
Merged
Conversation
POST /v1/models/{model_uid}/requests/{request_id}/abort read the body
with request.json() inside the handler's catch-all, so a call without a
body, as the 3D guide shows it, answered 500 "Expecting value" and never
reached the supervisor. A body that was valid JSON but not an object
also answered 500, and so did a block_duration that was not a number,
after the abort had already been forwarded: the model compares it with
0 once it has cancelled the running task.
An empty body now keeps the default block_duration. A body that is not
valid JSON, is not a JSON object, or has a non-number block_duration
answers 400 before anything is forwarded. Requests with a numeric
block_duration behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a paragraph after the request_id notes in client_api.rst, with the translation in every client_api.po catalog: the abort body is optional, the default block applies without one, and a body that is not a JSON object or a non-number block_duration returns HTTP 400 while the request keeps running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
qinxuye
reviewed
Dec 4, 2026
qinxuye
left a comment
Contributor
There was a problem hiding this comment.
I ran the three request-abort suites on c55ce9f6 and got 167 passes. The remaining findings are inline.
…path The route now accepts a fractional block_duration (1.5 is tested), but CancelMixin._cancel_running_task, ModelActor.abort_request and SupervisorActor.abort_request were annotated int, so mypy failed on restful_api.py once the route narrowed the value to int | float. asyncio.sleep already takes a float; annotate block_duration as float there and in both clients' abort_request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say that block_duration can be left out of a JSON object body and that the number rule applies only when it is present, in client_api.rst and every client_api.po catalog. In the Korean catalog, put a noun after the inline literals instead of a particle directly after the closing backticks, which the built page showed as literal backticks; this also fixes the media request ID paragraph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Bug
POST /v1/models/{model_uid}/requests/{request_id}/abortreads its body withrequest.json()inside the handler's catch-allexcept Exception. The 3D model guide (doc/source/models/model_abilities/3d.rst) documents the call as a plainPOSTto that path, andblock_durationhas a default, but a request without a body answers 500 and never reaches the supervisor:mainExpecting value ...block_duration30{"block_duration": 0}{Expecting property name ...Request body must be valid JSON[]'list' object has no attribute 'get'Request body must be a JSON objectnull'NoneType' object has no attribute 'get'Request body must be a JSON object{"block_duration": "30"},nullor[30]'>' not supported between instances of ..., after the abort was forwardedblock_duration must be a number, nothing forwarded{"block_duration": 1.5}The Python clients and the Web UI always send
{"block_duration": ...}, so they are not affected.Fix
Parse the body before the catch-all. An empty body becomes
{}, soblock_durationkeepsXINFERENCE_DEFAULT_CANCEL_BLOCK_DURATION. A body that is not valid JSON, or not a JSON object, answers 400. Ablock_durationthat is not a number also answers 400, checked before the abort is forwarded. Onmainit reaches the supervisor, andCancelMixin._cancel_running_task(used by the model actor and by this route) cancels the running task before it comparesblock_durationwith 0, so the client gets a 500 for an abort that has partly happened. With the supervisor stubbed, the 500 comes from the route's own_cancel_running_taskafter the supervisor call returned. A JSON object body with a numericblock_durationtakes the same path as before.Docs: a paragraph after the
request_idnotes indoc/source/user_guide/client_api.rst, with its translation in all tenclient_api.pocatalogs (de,es,fr,it,ja,ja_JP,ko,pt_BR,zh_CN,zh_TW), says the abort body is optional and so isblock_durationin it (the default block applies without either), and that a non-object body, or ablock_durationthat is present and not a number, returns 400 while the request keeps running. The Korean catalog also gets a markup fix (no particle right after a closing inline literal), including the mediarequest_idparagraph from #6294.Types:
block_durationis annotatedfloatthrough the cancellation path (CancelMixin._cancel_running_task,ModelActor.abort_request,SupervisorActor.abort_request) and in both clients'abort_request, since the route accepts fractional values (asyncio.sleeptakes a float).Inputs treated differently from
main: only the bodies in the table above that answered 500. Not changed:trueis still accepted as a number (it was a 1 s block onmain), and a negativeblock_durationstill means no block.Tests
test_abort_route_body_is_optionalinxinference/api/tests/test_llm_request_abort.pysends the bodies above through the real route with the supervisor stubbed. Onmainsource 8 cases fail (500) and the{"block_duration": 0}and1.5controls pass; with this change all 10 pass, the supervisor getsblock_duration30 for an empty body, and invalid bodies do not reach it.test_llm_request_abort.py,test_non_streaming_request_abort.pyandtest_anthropic_request_abort.pyinxinference/api/tests: 167 passed. Onmainsource the same files give 159 passed and 8 failed, the new cases only.msgfmt --checkpasses on the ten updated catalogs; the localized docs were not built.pre-commit run --from-ref=origin/main --to-ref=HEADpasses, and so doespre-commit run mypy --files xinference/api/restful_api.py xinference/core/utils.py xinference/core/model.py xinference/core/supervisor.py.Found while auditing xinference's request cancellation with Claude Code, which also wrote the fix and the tests.
🤖 Generated with Claude Code