makecindy / makecindy/cindy

bug: [mobile] 国际版构建产物未烘焙国内区清单自举地址,企业 SSO 双区探测失效,国内区组织报「未找到该企业」

Open
#3,861 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.7k
Forks
401
Avg merge
21h 48m
Merged PRs (30d)
776

Description

## 问题描述 / What happened

国际版(global,com.xd.cindy)Android 端「企业 SSO 登录」输入企业标识 `xd` 后提示「未找到该企业,或该企业未启用 SSO 登录。」(`ORG_SSO_NOT_FOUND` 文案),无法识别公司信息。多台设备复现,每次必现。

**期望行为**:按 `docs/auth-realm-routing.md` 的设计,国际版应并行探测两区 auth-server;该组织只存在于国内区,应弹出「切换区域」确认后引导完成 SSO。

**实际行为**:双区探测实际两次都打到国际区 `auth.cindy.app`,组织在国际区不存在 → 双侧均 404 → `ORG_SSO_NOT_FOUND`。

## 根因(已实证到产物级)

**全球线(global)发布的 JS bundle 里没有烘焙国内区清单自举地址** `https://hotfix.cindy.com.cn/cindy`(`EXPO_PUBLIC_ENDPOINT_MANIFEST_PEER_BASE_URL`)。运行期「国内区」被静默映射到国际区端点(拉到的"国内区清单"实为国际区 `endpoint.json`,该文件无 `region` 字段、现有校验不拦截),于是 cn 侧探测也落在 `auth.cindy.app`。

受影响产物(字符串表逐字节验证,均无 `https://hotfix.cindy.com.cn/cindy`,仅有无关的媒体桶 `…/cindy-media`):

| 产物 | 构建时间 | 跨区域发现代码 | 国内区清单地址 |
|---|---|---|---|
| 0.1.9 整包内嵌 bundle(com.xd.cindy, versionCode 17) | 2026-08-31 | ✔ 存在 | ✘ 缺失 |
| OTA release 通道 bundle(update id `2a685d86`) | 2026-09-01 | ✔ 存在 | ✘ 缺失 |
| OTA beta 通道 bundle(0.1.72 beta,update id `6defe5de`) | 2026-09-02 | ✔ 存在 | ✘ 缺失 |

仓库源码本身是正确的:跨区域发现逻辑(#748,2026-07-28 合入)、`apps/mobile/app.config.js` 的 `resolvePeerManifestBaseUrl`、`scripts/shared/client-endpoint-build-env.{mjs,cjs}` 推导出的 peer 值均为正确的 `https://hotfix.cindy.com.cn/cindy`。缺陷在出包/OTA 发布环境的 env 注入环节。可疑点:`app.config.js:221-223` 对已有 `process.env` 值采取保留语义(`if (!process.env[key]?.trim())`),打包机/流水线残留 `EXPO_PUBLIC_ENDPOINT_MANIFEST_PEER_BASE_URL` 时会盖过仓内推导值。

补充说明:peer 运行值判定为「被烘成本区地址」而非「空值」,依据是报错文案——peer 为空时按 `env.ts` 的 `loadMobileEndpointsForRealm` 会抛 `realm-manifest-url-unavailable` → `ORG_REALM_UNAVAILABLE`(文案「暂时无法确认企业所在区域」),与实测文案不符;两种情形下修复动作相同。

## 环境 / Environment

- Cindy 版本:com.xd.cindy 0.1.9(versionCode 17)+ OTA beta 通道(bundle 含 0.1.72 标记)
- 平台:Android 15(Xiaomi 24053PY09C,MIUI);另有多台 Android 设备复现
- 安装方式:自建线侧载 APK + 自建 OTA(mobile-update.cindy.app)

## 复现步骤 / Steps to reproduce

1. 安装国际版 com.xd.cindy(0.1.9 整包),放行 OTA 至当前 release/beta 任一通道最新。
2. 登录页进入「企业 SSO 登录」,输入 `xd`,点「继续」。
3. 必现提示「未找到该企业,或该企业未启用 SSO 登录。」

## 诊断证据 / Logs & screenshots

1. **服务端数据正常**(复现设备同网络直接 curl,均 200/404 在亚秒内返回):
- `POST https://auth.cindy.com.cn/api/auth/sso/discovery` `{"org":"xd"}` → 200 `{"region":"cn","orgName":"心动网络","connections":[{"connectionId":"…","protocol":"saml","connectionName":"心动"}]}`
- `POST https://auth.cindy.app/api/auth/sso/discovery` `{"org":"xd"}` → 404 `{"error":{"code":"ORG_SSO_NOT_FOUND",…}}`
2. **App 复现期间从未连接任何 `*.cindy.com.cn` 主机**:对 App 进程(uid)150 秒 `/proc/net/tcp[6]` 全程采样(0.3s 间隔),仅见 `8.222.152.122`(auth.cindy.app)与 `43.175.x.x`(hotfix.cindy.app CDN)两类 443 连接。
3. **产物字符串表检查**:三份 bundle 中 `https://hotfix.cindy.com.cn/cindy` 唯一出现处以 `-media` 结尾(媒体桶 URL);清单自举地址仅 `https://hotfix.cindy.app/cindy` 一条。跨区域代码与文案(`ORG_REALM_UNAVAILABLE`、`realm-switch-required`、双区文案)均在 bundle 中,排除「代码未发布」。
4. **对照**:国内版(com.xd.cindycn)自身区域即 cn,org 同区可命中(建议作为修复后对照验证)。

## 修复建议

1. 清理全球线打包/发布环境的 `EXPO_PUBLIC_ENDPOINT_MANIFEST_*` 残留后重新出包并重发 OTA(release 与 beta 两通道)。验收标准:产物 bundle 字符串表中存在 `https://hotfix.cindy.com.cn/cindy`;国际版输入 `xd` 出现「切换区域」确认而非报错。
2. 顺带核查 iOS 全球版(store-global / testflight-global)是否同样带病(EAS 环境 env 来源不同,需单独验证)。
3. 建议增加构建期断言(可单独 PR):非 dev 构建强制 `EXPO_PUBLIC_ENDPOINT_MANIFEST_PEER_BASE_URL` 与 `…_BASE_URL` 均非空且不相等,fail-fast,防止静默错配再次流出;并可考虑对端清单加载时对「peer 与本区同 URL」直接报诊断码。

## 临时绕过

修复发布前,受影响用户可使用国内版(com.xd.cindycn)完成企业 SSO 登录(组织在国内区,同区发现可直接命中)。

Contributor guide

Open the contributing guide

Research direction

Start with apps/mobile/app.config.js:221-223 and scripts/shared/client-endpoint-build-env.{mjs,cjs}, then trace how global build and OTA environments inject the endpoint variables. Rebuild the release and beta artifacts and inspect their bundle strings for the cn peer URL; verify global SSO for `xd` shows the region-switch confirmation, and separately check the global iOS environments.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
build-system, mobile, release
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.