UI: store.getters.zones.filter is not a function on first login for User-type roles (race between listZones and listApis)

未关闭 适合新手
#14,847 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript
领域
frontend

调研方向

从 ui/src/store/modules/user.js 开始,跟踪 GetInfo 以及 listZones、listApis 和 GenerateRoutes,确认报告的竞态。然后检查 ui/src/config/section/network.js 中的 show 函数和 vnfapp 详情,查找其他未受保护的 zone 查询。当使用所述角色重新登录后页面加载时不再出现控制台错误,issue 即告完成;请在新的隐私会话中验证所报告的行为。

由索引模型根据 Issue 内容生成。

描述

bug
problem

On a fresh session the UI stays empty and the console shows:

TypeError: store.getters.zones.filter is not a function
    at Object.show (network.js)
    ...
    at GenerateRoutes (permission.js)

A reload (F5) fixes it. We see it for users with a User-type role and a short API list; a DomainAdmin user with a longer API list usually does not hit it.

Cause: in ui/src/store/modules/user.js the state starts with zones: {} (an object, not an array). GetInfo starts listZones and listApis in parallel and dispatches GenerateRoutes as soon as listApis returns, without waiting for listZones. When listApis returns first, the show of the securitygroups section in ui/src/config/section/network.js calls store.getters.zones.filter(...) on {}. The createNetwork show and the vnfapp details have the same unguarded call. On a reload the cached branch of GetInfo commits the zones from local storage before anything else, so there is no race.

versions

Apache CloudStack 4.22.1.0 (management server and UI), KVM, advanced zones. Login via SAML2 (Keycloak). The same code (zones: {} and no wait on listZones before GenerateRoutes) is on the 4.22 branch and on main.

The steps to reproduce the bug
  1. Create a custom role of type User with a short allow-list that includes listApis, listZones, listSecurityGroups, listUsers, listCapabilities, listLdapConfigurations, listNetworkServiceProviders and cloudianIsEnabled, ending with *,deny.
  2. Create an account with that role and a user, and authorise the user for SAML.
  3. Open a new private browser window and log in through SAML.
  4. In the network tab, listApis returns before listZones; the UI stays empty and the console shows store.getters.zones.filter is not a function.
  5. Press F5: the UI loads normally.

It is timing dependent: the shorter the API list of the role, the more often listApis wins.

What to do about it?
  • Initialise zones as [] in the state of ui/src/store/modules/user.js.
  • Wait for listZones (and SET_ZONES) before dispatching GenerateRoutes in GetInfo.
  • Guard the show functions in ui/src/config/section/network.js (and the vnfapp details) with Array.isArray(store.getters.zones).

Any one of the first two fixes the race; the guard makes the menu robust against a missing zone list.

主要语言
Java
星标
3.1k
派生
1.4k
平均合并
6 天 1 小时
30 天内合并 PR
16

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/cloudstack 的其他 Issue

查看 apache/cloudstack 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。