Repository navigation
fix(api): 支持空请求体查询全部队列、计划与托管配置 - #2135
Open
sentry[bot] wants to merge 2 commits into
Open
sentry[bot] wants to merge 2 commits into
sentry[bot] wants to merge 2 commits into
Conversation
Contributor
总体结论:修改后合并
还有一处得一起更新。后端把请求体改成可省略,但生成的前端接口仍要求传入对象,例如 让接口和客户端说同一句话的 dot酱 |
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.
问题背景
当 MCP 客户端以空参数调用工具(例如查询全部调度队列、全部计划或全部托管)时,fastapi-mcp 不会发送请求体。
由于
/api/queue/get、/api/plan/get与/api/scripts/get接口的入参声明为Body(...),FastAPI 会因为请求缺少请求体而拒绝并返回 HTTP 422({"loc": ["body"], "msg": "Field required", "input": null})。然而这三个接口对应的输入模型(
QueueGetIn、PlanGetIn、ScriptGetIn)中仅包含可选的 ID 字段,其设计契约本身即为「未携带时表示获取全部数据」。解决措施
/api/queue/get、/api/plan/get、/api/scripts/get的路由参数改为Body(default_factory=...),在客户端未携带请求体时直接按全部查询的默认输入模型处理,不再抛出 422。queueId的时间设置和队列项查询接口)现有的Body(...)契约不变。Fixes AUTO-MAS-BACKEND-36
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry. You can adjust this setting at any time.