-
Notifications
You must be signed in to change notification settings - Fork 11
fix(): throw unauthenticated error when fetch contracts failed #4830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough在远程获取流程API定义时,对未认证错误添加了特殊处理。当批量合约获取抛出错误时,现在会检测是否为未认证错误,若是则重新抛出;之前未认证错误被作为通用故障处理和记录。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 分钟
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v3 #4830 +/- ##
==========================================
- Coverage 95.16% 95.14% -0.03%
==========================================
Files 212 212
Lines 9357 9359 +2
Branches 1802 1803 +1
==========================================
Hits 8905 8905
- Misses 332 334 +2
Partials 120 120
🚀 New features to boost your workflow:
|
next-core
|
||||||||||||||||||||||||||||
| Project |
next-core
|
| Branch Review |
steve/v3-flow-api-not-found
|
| Run status |
|
| Run duration | 00m 24s |
| Commit |
|
| Committer | Shenwei Wang |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
17
|
| View all changes introduced in this branch ↗︎ | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/easyops-runtime/src/flowApi/FlowApi.ts (1)
284-287: 未认证错误改为上抛的行为符合预期,但要注意调用方和缓存语义这里在批量合约查询失败时,若
isUnauthenticatedError(e)为真就直接throw e,其余错误则仍然记录在本地error变量并最终打印日志、返回null。这基本符合 PR 的目标:让未认证错误走统一的上层处理链路(如登录拦截),而不是被当成 “Flow API 不存在/查询失败”。几点小建议和注意点:
调用方行为变化
- 之前:未认证错误会被吞掉,调用
fetchFlowApiDefinitionFromRemote的地方只会拿到null(通过fetchFlowApiDefinition再转成FlowApiNotFoundError等逻辑)。- 现在:未认证会直接 reject Promise。请确认上层调用链(例如
getArgsOfFlowApi的使用者)都有统一的全局错误处理,不会因为新增的 reject 导致未捕获异常或 UI 行为变化超出预期。与缓存
remoteContractCache的交互
- 当前逻辑里,
fetchFlowApiDefinitionFromRemote(...)返回的 Promise 会被直接缓存到remoteContractCache中。- 之前:未认证场景最终 resolve 为
null,相当于缓存了一个 “负结果”;- 现在:未认证场景会缓存一个 rejected Promise。在同一运行时中如果之后用户完成登录,但没有重启/重置 runtime,这个 provider 的后续请求依然会直接沿用已 rejected 的 Promise。
- 这个行为与之前缓存
null的“不会重试”语义是一致的,但如果未来希望在同一运行时里支持“登录后自动重试获取契约”,可以考虑在上层登录/登出流里清空remoteContractCache,或者只在成功获取合约后再写入缓存。整体来看改动没有明显正确性问题,语义也与 PR 描述一致,上述只是后续演进可以关注的点。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
packages/easyops-runtime/src/flowApi/FlowApi.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build (20.x)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/easyops-runtime/src/flowApi/FlowApi.ts (1)
14-14: 引入isUnauthenticatedError与下方用法一致从
@next-core/runtime引入isUnauthenticatedError,与后续在catch分支中的使用保持一致,没有多余引用,整体合理。建议确认下该 helper 在当前版本下对
ContractCenterApi_batchSearchContract抛出的未认证场景(例如 401、登录态过期等)都能正确识别,避免误判导致真正的未认证错误被当作普通失败走到日志/null的分支。
依赖检查
组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。
请勾选以下两组选项其中之一:
或者:
提交信息检查
Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。
破坏性变更:
feat作为提交类型。BREAKING CHANGE: 你的变更说明。新特性:
feat作为提交类型。问题修复:
fix作为提交类型。杂项工作:
即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:
chore,docs,test等作为提交类型。Summary by CodeRabbit
发布说明
✏️ Tip: You can customize this high-level summary in your review settings.