已合并
【fix】修复 `ResourceRegistry` 加载编译资源 manifest 时允许空 `resource_id` 的问题 #5319
好好说话95号创建于 24 天前
【fix】修复 `ResourceRegistry` 加载编译资源 manifest 时允许空 `resource_id` 的问题 #5319
已合并
好好说话95号创建于 24 天前
好好说话95号
好好说话95号成员
24 天前

描述

修复 ResourceRegistry 加载编译资源 manifest 时允许空 resource_id 的问题。

同时在 tests/tools/aclrtc/test_resource_registry.cpp 中补充回归测试:

  • 覆盖 LoadManifest() 直接加载空 resource_id manifest 的场景,断言返回 InvalidResource 且 stage 中不包含空 key。
  • 覆盖公开 Load() 加载 bundle 的场景,断言包含空 resource_id 的非法 bundle 不会提交任何资源,同时保留合法 bundle 可正常加载和查询的对照。

关联的Issue

关联Issue:ResourceRegistry 加载 manifest 时缺少空 resource_id 校验

测试

文档更新

无文档更新。

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 好好说话95号 的贡献)
好好说话95号好好说话95号成员
24 天前 创建了 pull request,commit a3546c6f
atomgit-bot
atomgit-bot
24 天前 评论:

变更摘要

本 PR 修复 ResourceRegistry 加载编译资源 manifest 时允许空 resource_id 的问题,并补充相应回归测试。核心改动是在 tools/aclrtc/specialization/resource_registry.cppParseResourceId() 中新增对空 resource_id 的校验:当解析出的 resource_id 为空字符串时记录错误日志(ASCENDLOGE)并返回 ResourceStatus::InvalidResource,从而阻止空 resource_id 的 manifest 被接受。同时在 tests/tools/aclrtc/test_resource_registry.cpp 中新增回归用例,覆盖直接加载空 resource_id manifest 以及通过公开 Load() 加载包含非法 bundle 的场景。

主要改动

  • ParseResourceId() 增加空值校验:在 tools/aclrtc/specialization/resource_registry.cpp 中,解析 resource_id 后若结果为空字符串,则输出包含 source_typesomanifest 等字段的错误日志并返回 ResourceStatus::InvalidResource
  • 补充直接加载空 resource_id manifest 的断言:在 LoadManifestValidatesJsonOwnershipSourceAndDuplicate 测试中新增 EXPECT_EQ(loadText(R"({"resource_id":""})"), ResourceStatus::InvalidResource),并断言 stage 的 external resources 中不包含空 key。
  • 新增公开 Load() 的回归测试:新增 LoadRejectsEmptyResourceIdAndDoesNotCommitPartialBundle 用例,构造"合法 manifest + 空 resource_id manifest"的非法 bundle,断言 Load() 返回 InvalidResourceFindResource("")FindResource("valid-resource") 均为空(非法 bundle 不会提交任何资源);随后加载仅含合法 manifest 的 bundle,断言返回 SuccessLookup("valid-resource") 可正常查询到资源。
likedislike
不准确?
atomgit-bot
atomgit-bot
24 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
24 天前 添加了label:cann-cla/yes
好好说话95号
好好说话95号成员
24 天前 评论:

compile

likedislike
CANN-robot
CANN-robot成员
24 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/asc-devkit sjtulxh, chenyiyuan, YANXI_ZHAO (3/2) sjtulxh, chenyiyuan, YANXI_ZHAO (3/1)
tools/aclrtc chenyiyuan, YANXI_ZHAO, sjtulxh (3/2) YANXI_ZHAO (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

huxj153, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
好好说话95号好好说话95号成员
24 天前 预合并成功(commit_id: b622fbb2e8f6b91413a5d8deaa2c6adf9a3a6b6c)
CANN-robotCANN-robot成员
24 天前 将zengjuan,zhanghao_0689,wk0911,suqwe,wulinyu,kong0808,dengjing_aoe,YeZZzzz1,bluesky901,yangbinhua,zhudi22,chenyiyuan,xun_zhuge,XuebinYang,sjtulxh,bianque,houyuyang,Lycheeeee,YANXI_ZHAO,chentianyu19,shi_nanxiang,wuyang_hw,jiangxinyu3,ascendhjh,hujiawen_kaven,wangxiaozhi,DragonBornHD84,louyuxuan,hyolee,yukangchen设为评审人
CANN-robotCANN-robot成员
24 天前 将zengjuan,zhanghao_0689,wk0911,suqwe,wulinyu,kong0808,dengjing_aoe,YeZZzzz1,bluesky901,yangbinhua,zhudi22,chenyiyuan,xun_zhuge,XuebinYang,sjtulxh,bianque,houyuyang,Lycheeeee,YANXI_ZHAO,chentianyu19,shi_nanxiang,wuyang_hw,jiangxinyu3,ascendhjh,hujiawen_kaven,wangxiaozhi,DragonBornHD84,louyuxuan,hyolee,yukangchen设为审查人
CANN-robotCANN-robot成员
24 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
24 天前 评论:

流水线任务触发成功
任务链接 [ff60d431208d479ab7562ce94276f7ea][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck ✅ SUCCESS >>>>>
codecheck_Pr ✅ SUCCESS
pre_comment ✅ SUCCESS >>>>>
codecheck_codestyle ✅ SUCCESS >>>>>
codecheck_precommit ✅ SUCCESS >>>>>
StaticCheck_md ✅ SUCCESS

[2026-08-25 14:17:55]    CI执行结束

likedislike
gao_dafa成员
24 天前 评论:

huxj153,感谢您的提交,建议在完成PR充分自验证后,再触发线上构建任务。

若您的PR已具备检视条件,可根据下表的责任田,@对应的committer进行代码检视,我们会在第一时间对您的提交进行处理。

代码责任田:

module committer
adv_api chenyiyuan, wuyang_hw
basic_api chenyiyuan, wuyang_hw
c_api pangfd, haipingmao
cmake xun_zhuge, DragonBornHD84
docs munanhw, ai_xin
examples changxianyu, bianque
simt_api wulinyu, zhanghao_0689
scripts xun_zhuge, kevin365
tools YANXI_ZHAO, XuebinYang, sjtulxh

💡 如您不确定可以@谁,可以直接@我或者ascend-c sig的maintainer,xun_zhugeascendhjh,我们会为您分配合适的committer进行代码检视。

再次感谢您参与CANN的社区贡献。

likedislike
CANN-robot
CANN-robot成员
24 天前 评论:

流水线任务触发成功
任务链接 [21ffc4d365604606a62645a3de365964][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>

[2026-08-25 14:25:42]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
24 天前 评论:

流水线任务触发成功
任务链接 [749b7fe311fc4674a8e189abd69f5b75][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
UT_Test_adv_test_one ✅ SUCCESS
UT_Test_adv_test_two ✅ SUCCESS
UT_Test_basic_test_one ✅ SUCCESS
UT_Test_basic_test_two ✅ SUCCESS
UT_Test_basic_test_three ✅ SUCCESS
UT_Test_basic_test_four ✅ SUCCESS
UT_Test_basic_test_five ✅ SUCCESS
UT_Test_arm ✅ SUCCESS
API_Check ✅ SUCCESS >>>>>
UT_Test_report ✅ SUCCESS >>>>>

[2026-08-25 14:28:24]    CI执行结束

likedislike
CANN-robotCANN-robot成员
24 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
24 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
24 天前 添加了label:ci-pipeline-passed
好好说话95号好好说话95号成员
24 天前 关联了issue:[Bug-Report|缺陷反馈]: ResourceRegistry 接受空 resource_id 并注册不可查询的资源
sjtulxh成员
21 天前 评论:

/lgt

likedislike
sjtulxh成员
21 天前 评论:

/lgtm
/approve

likedislike
chenyiyuan成员
21 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:lgtm
YYANXI_ZHAO成员
21 天前 通过审查
YYANXI_ZHAO成员
21 天前 通过了评审
YANXI_ZHAO成员
21 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:approved
CANN-robotCANN-robot成员
21 天前 合入了pull request