mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #681] [CLOSED] serve: a malformed "tools" is a 400, not a dead request thread #2760
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2760
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/681
Author: @hireymage
Created: 10/3/2026
Status: ❌ Closed
Base:
main← Head:fix-tools-400📝 Commits (1)
176850cserve: a malformed "tools" is a 400, not a dead request thread📊 Changes
2 files changed (+45 additions, -4 deletions)
View changed files
📝
serve/frontend.py(+19 -4)📝
serve/test_server.py(+26 -0)📄 Description
Issue: #592
A request whose
"tools"is not the list of tool objects it is meant to be ("auto",["get_weather"], a barenumber, a dict) took the request thread down with an
AttributeError— the connection closes with no reply atall, a reverse proxy shows a 502. It happened two lines apart, both still on main:
serve/frontend.py— the OpenAI mapping handed non-dict entries on unchanged, and the next consumer(
serve/server.py,own = {t.get("name") for t in tools or []}) assumed every entry is a mapping;serve/frontend.py's Anthropic path had the same shape one level earlier (t["name"]on a non-dict).The fix
The same treatment double-encoded
"messages"got in #460 (_object_list): what is not a list of object-shapedtools is a
ValueErrornaming the field, which the server answers with its 400invalid_request_error:function-type entry needs its"function"object with a non-empty"name", the llama style needs a name (the working shape from the issue's repro{"name": "get_weather"}keeps working exactly as before);
Tests
serve/test_server.py'stest_tools_must_be_an_object_listcovers the crashing shapes from the issue end to end,the entry-level rejections (a
functionentry without its function object, an empty or non-string name), thedouble-decode, and the valid shapes mapping as before (119 tests, suite green).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.