已合并
fix(om2): report visual JSON extraction errors #4403
ClarkXie创建于 6 天前
fix(om2): report visual JSON extraction errors #4403
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 ClarkXie 的贡献)atomgit-bot
6 天前 评论:
6 天前 评论:
变更摘要
本 PR 主要针对 Om2PackageHelper::ExtractVisualJson 在 OM2 visual JSON 提取失败时补充对外错误码上报能力:新增 report_extract_failed 辅助逻辑,通过 REPORT_PREDEFINED_ERR_MSG 上报 E10059 错误码并记录日志,同时将 ZIP 打开失败、未找到 visual JSON、visual JSON entry 提取失败/内容为空这几类场景由原断言改为显式上报并返回 FAILED。model_data、model_len 的防御性校验保持不变。同时补充了相应单元测试,覆盖非法 ZIP、缺失 visual JSON 及损坏 visual JSON entry 三类失败场景。
主要改动
- 新增错误码上报封装: 在
ExtractVisualJson内引入report_extract_failedlambda,统一调用REPORT_PREDEFINED_ERR_MSG上报E10059(带stage、reason信息)并通过GELOGE输出失败原因。 - 失败路径改为显式上报并返回: 将
reader.IsGood()失败、entry_path为空、json_buf == nullptr或json_size == 0U三处原GE_ASSERT_TRUE/GE_ASSERT_NOTNULL断言改为if判断,调用report_extract_failed后返回FAILED。 - 保留原有防御性校验:
model_data空指针检查(GE_ASSERT_NOTNULL)和model_len零长度检查(GE_ASSERT_TRUE)未被改动,仍不额外上报预定义错误码。 - 补充单元测试覆盖: 在
ExtractVisualJson_Fail_InvalidZip与ExtractVisualJson_Fail_NoVisualJson中增加对E10059上报的断言;新增ExtractVisualJson_Fail_CorruptedVisualJsonEntry,构造含 visual JSON 的 ZIP 并篡改 local file header 以验证损坏场景的上报。


atomgit-bot
6 天前 评论:
6 天前 评论:
6 天前 添加了label:cann-cla/yes
CANN-robot
6 天前 评论:
6 天前 评论:
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
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/ge | ✅ yangyongqiang0606, zhangfan_hanq, yuht9 (3/2) | ✅ yangyongqiang0606 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
ClarkXie, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了47条消息 查看更多
6 天前 添加了label:lgtm
yangyongqiang
6 天前 评论:
6 天前 评论:
/approve


6 天前 添加了label:approved
6 天前 合入了pull request
Pull Request
描述
OM2 包 visual JSON 提取失败场景(非法 ZIP、缺失 visual JSON、损坏 visual JSON entry)此前仅通过 GE_ASSERT 记录日志,未向用户上报对外错误码,问题难以定位。
本次变更:
变更类型
请选择本次引入的变更类型:
关联的Issue
如何测试
描述测试此变更的步骤和前提条件:
om2_package_helper_unittest,覆盖ExtractVisualJson_Fail_InvalidZip、ExtractVisualJson_Fail_NoVisualJson、ExtractVisualJson_Fail_CorruptedVisualJsonEntry用例。ErrorManager能查询到 E10059 错误码上报。核对清单
其他信息
本次变更仅涉及错误码上报逻辑与 UT 用例,无文档变更。