Merged
fix(registry): reject size=0 on the services list endpoint #348
fix(registry): reject size=0 on the services list endpoint #348
Merged
庄昭雄Add on Oct 18
庄昭雄
庄昭雄
Oct 18

Paired: GitHub #144 ↔ GitCode !348

probe

likedislike
Pull Request has been successfully merged by openJiuwen-bot.
(Thank you for 庄昭雄's contribution.)
atomgit-bot
atomgit-bot
Oct 18 Comments:

变更摘要

本 PR 修复 AgentRegistry/a2x_registry/backend/routers/dataset.py 中 list_services() 端点对 size=0 的处理缺陷。此前 size 参数校验允许 0 通过,进入分页逻辑后因 (total + size - 1) // size 触发除零,导致 GET /api/datasets/{dataset}/services?size=0 返回 HTTP 500。改动在读取 registry 之前增加对 size == 0 的显式校验,抛出 HTTPException(400),并将 size 语义限定为 -1(全部)或正数页大小;-1 与正数分页行为保持不变。同时新增测试文件 test_dataset_pagination_size_zero.py,通过 fake registry service 直接调用路由函数验证该边界行为。

主要改动

  • 拒绝 size=0 参数: 在 list_services() 中 fields 校验之后新增 if size == 0 判断,抛出 HTTPException(status_code=400, detail="size must be -1 (all) or a positive page size, got 0"),使该输入由客户端错误取代原先的 ZeroDivisionError(500)。
  • 保持分页既有语义: 校验仅拦截 0,size=-1(返回全部)与正数页大小的分页路径不发生变化。
  • 新增回归测试: 新增 AgentRegistry/tests/backend/test_dataset_pagination_size_zero.py,通过 monkeypatch 注入 fake registry service 与 request/response 桩对象,断言 size=0 时抛出状态码为 400 且 detail 中含 size 的 HTTPException。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Oct 18 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
OopenJiuwen-botCollaborators
Oct 18 Set YiyangShao,xinyu-jiuwen as approver
atomgit-bot
atomgit-bot
Oct 18 Comments:

AtomGit AI 助手使用指南

在 PR 评论中使用命令即可触发。支持在普通评论和代码行评论中使用。

功能 命令 说明
代码审查 /ai review 检查代码质量、潜在问题、安全风险
PR 摘要 /ai summary 生成 PR 变更内容的结构化摘要
代码解释 /ai explain 解释代码变更的逻辑和意图
自由提问 @atomgit-bot <问题> 询问关于本 PR 的任何问题
帮助 /ai help 显示此帮助信息

免责声明

AI 助手可能存在误判,请结合自身判断。可以对评论点 👍 或 👎 帮助我们改进。

likedislike
Incorrect?
OopenJiuwen-botCollaborators
Oct 18 Added label: sig/sig-agent-protocol
openJiuwen-botCollaborators
Oct 18 Comments:

欢迎来到 openJiuwen 社区

Hey @grandocean , 感谢你对社区的贡献.

机器人使用手册

有关指令的使用,可以点击 此处 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。

联系指引

有疑问可以联系 SIG: sig-agent-protocol ,
维护者是: @YiyangShao, @xinyu-jiuwen ,
审核者是: @gcw_hx9prznZ, @mingo007 .

likedislike
OopenJiuwen-botCollaborators
Oct 18 Added label: openJiuwen-cla/yes
庄昭雄庄昭雄
Oct 18 Modify description of pull request
Oopenjiuwen-syncCollaborators
Oct 18 Modify description of pull request
openJiuwen-botCollaborators
Oct 18 Comments:

The pipeline(pipeline number:348) is running. Please wait a moment...

likedislike
OopenJiuwen-botCollaborators
Oct 18 Added label: ci-running
OopenJiuwen-botCollaborators
Oct 18 Removed label: ci-running
openJiuwen-botCollaborators
Oct 18 Comments:
任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
likedislike
OopenJiuwen-botCollaborators
Oct 18 Added label: ci-successful
zhengwCollaborators
29 days ago Comments:

代码方案没有问题,但测试用例使用了不在依赖中的pytest-asyncio插件,需要规避一下。
另外,当前后端测试用 lite_app TestClient 发真实请求。
考虑删除测试用例后再合入PR,或者调整测试用例。

likedislike
zhengwCollaborators
22 days ago Comments:

@grandocean 你好,完成相关检视意见即可合入,请问您还打算完善这个PR吗?

likedislike
庄昭雄庄昭雄
22 days ago Pushed 1 commits:eeb12860-test(registry): pin the size=0 rejection through the real backend client
OopenJiuwen-botCollaborators
22 days ago Added label: stat/needs-squash
OopenJiuwen-botCollaborators
22 days ago Removed label: openJiuwen-cla/yes
OopenJiuwen-botCollaborators
22 days ago Removed label: ci-successful
庄昭雄
庄昭雄
22 days ago Comments:

已完成检视意见,推送 eeb1286:

  • 删掉了 pytest-asyncio 的用法,tests/backend/test_dataset_pagination_size_zero.py 改为用与其它后端测试相同的 lite_app TestClient 发真实请求;
  • 回归验证:在没有 handler 修复时,GET /api/datasets/{dataset}/services?size=0 触发 ZeroDivisionError(500);加修复后返回 400,detail 含 size;
  • 另加一条 size=-1 的正常路径,确保没有误伤全量返回。

本地:pytest tests/backend -q → 9 passed(含新增 2 条)。

麻烦再 review 一下,谢谢!

likedislike
openJiuwen-botCollaborators
22 days ago Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-successful.

likedislike
OopenJiuwen-botCollaborators
22 days ago Added label: openJiuwen-cla/yes
openJiuwen-botCollaborators
22 days ago Comments:

The pipeline(pipeline number:348) is running. Please wait a moment...

likedislike
OopenJiuwen-botCollaborators
22 days ago Added label: ci-running
OopenJiuwen-botCollaborators
22 days ago Removed label: ci-running
openJiuwen-botCollaborators
22 days ago Comments:
任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ❌FAILED 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A
likedislike
OopenJiuwen-botCollaborators
22 days ago Added label: ci-failed
庄昭雄庄昭雄
21 days ago Force-pushed 1 commits:a8797af4-test(registry): pin the size=0 rejection through the real backend client
OopenJiuwen-botCollaborators
21 days ago Removed label: openJiuwen-cla/yes
OopenJiuwen-botCollaborators
21 days ago Added label: openJiuwen-cla/yes
openJiuwen-botCollaborators
21 days ago Comments:

CLA 签署成功

grandocean, 感谢您的代码贡献。 所有的代码贡献者都已完成了 CLA 签署。 👍

likedislike
openJiuwen-botCollaborators
21 days ago Comments:

The pipeline(pipeline number:348) is running. Please wait a moment...

likedislike
OopenJiuwen-botCollaborators
21 days ago Removed label: ci-failed
OopenJiuwen-botCollaborators
21 days ago Added label: ci-running
OopenJiuwen-botCollaborators
21 days ago Removed label: ci-running
openJiuwen-botCollaborators
21 days ago Comments:
任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
likedislike
OopenJiuwen-botCollaborators
21 days ago Added label: ci-successful
Yiyang ShaoCollaborators
6 days ago Comments:

/lgtm
/approve

likedislike
OopenJiuwen-botCollaborators
6 days ago Added label: approvedlgtm-YiyangShao
openJiuwen-botCollaborators
6 days ago Comments:

Review Code Feedback

  • The label lgtm-YiyangShao, approved was added to this pull request. It means that YiyangShao reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
OopenJiuwen-botCollaborators
6 days ago Merged pull request
OopenJiuwen-botCollaborators
6 days ago Removed label: ci-successful